Dashboard variables, dashboard variables allow more interactivity with your dashboard, so you can
dynamically update them, many things can be turned into dashboard variables.
I have a whole list of them here that will go through, but we use all of the data sources that we've
created so far and create different dashboard variables from them.
So you can see it's quite a few there.
So what a dashboard variable looks like if I look at the node exporter dashboard here.
These dropdowns, they are created from dashboard variables.
So here we have some values dynamically added, and if I change one of those to go farther than all
the dashboard updates, depending on that.
So if I select Influx DB, we get information about the influx DB, ServiceNow and Moscow, for example.
Now each of these visualizations here are rating the value behind this particular dashboard variable
to know which host to get his data from.
So if I look at this table here and just press a we can see inside the queries is a dollar node that
is referring to the dashboard variable just here.
So we'll create dashboard variables now looking at all of the different data sources that were credit
so far.
So go into dashboards, manage, discard any changes he made on that dashboard, create a new dashboard
and we'll go straight to dashboard settings.
So I'm going to call it dashboard variables.
OK, save that, OK.
Go back into settings now there's this option here called variables at a variable.
We have many types of variables.
The first one will be a type of interval so that select interval and it's pre created a list for us
already.
I'm going to call the variable interval that nightmare interval.
That means within my visualizations, I'll refer to that as the interval, but I won't use.
$$ in the name here because it's not on the correct, but I'll demonstrate using these in the next few
videos.
But down here you can see a preview of values.
We can add more if we like.
So I can say give me 60 days or one year or 10 years.
For example, 60 days, one year to one year, I can say, give me 10 seconds and ten seconds is a list.
So if I update, that is now showing up as an interval.
If I press that back error that dropdown now exists in my dashboard, I can use that $ interval in my
visualizations.
Also see here how I got the word interval and it's a lowercase I.
I can actually improve on that presentation slightly by going back into variable, clicking it and saying
the display name can be interval.
So my display name of using a capital I.
That my variable name is a little high.
So if you ever want your variable names to be more programmatic looking such as my interval, but you
don't want to show that as your label.
Then you use label here, Thelma, keep that just a lowercase I at that update.
So that's how those dropdowns are created.
That's a very simple one.
The next one will create a custom.
So a new custom, I'm going to call it custom, but my label is going to be custom.
A custom variable is my description.
Comma separated values.
Just copy that.
ABC, I think that's the preview down there.
No.
One to three.
Anything I like.
OK, so there's the preview down there.
Now these multi value and include all option, let's have a look at what we have first.
So uptight that going to there and that's the custom with all my custom comma separated values go back
into it.
Variables custom.
If I select Multi Value and Press Update, go back, I can now select one or none to or what that or
all except for one.
Now, looking at variable skin, they include all option.
All that does is shows update an option like that.
So that means all.
Anyway, moving on a data source type.
OK, so variables new, the type will be a data source.
Cool data source.
And my label complete data source like that type again, referring to which data sources we have configured.
I have quite a few.
I'm going to use ElasticSearch for this example.
And down here it's show me all my ElasticSearch data sources.
So if I update that and view that so I can select whichever data source I want to use for a particular
use case.
I go back into that variables looking at that, also this instance name filter, these are rejects as
most of the variable types have this option.
So what I can say is I can say, give me everything with the word file in it, so I might have many
ElasticSearch data sources configured and they might be something similar, such as the word file,
for example.
So I'd say, give me everything with the word file in it.
And it's given me Volbeat or give me everything with the word metric, or if we look at this first dot
here, that means anything before the metric.
So if I was to type a plastic, for example, the plastic that wouldn't show anything because it's looking
for something for the word logistic support that got away.
It's now show me everything starting with elastic.
Give me everything ending with beat for beat metrically.
Or just give me everything.
But that's the same as just doing that.
OK, excellent.
So update that ElasticSearch, Volbeat.
OK, next one is still school query, we can run a direct MySchool query on our data source, so variables
new, this will be a query.
OK, I'm going to call this username optional.
Use a name.
I'm going to use my my squirrel data source and the query being that they select username as metric
from the example simple table that we set up at the beginning of the course when we're looking at non
time series data or body, click here.
Show me all the names from that flat static table we credit very good updated and username.
And you can dynamically update your visualizations based on that variable called username.
Just their username would be.
That's how it refer to it, anyway, let's create another one.
New.
OK, we'll do some low-key queries first one label names, I'll call it name query label, low key names,
low key and that's my query.
Label names and it's just given me everything I can find on the label names for name host job update
that outside the dashboard safe, we're going to explore the low key data source, low key.
And if I slipped log browser, they're there.
The name is their full name host job.
I'm carrying a variable with those three plus a system level name, so manage.
Dashboard variables added that variables, label names, we get the X-1 down here, which is a system
level name we can hide that be a little bit more tricky with this one.
So that's an example.
That means in rejects the start of a line where he is saying not subject to the same thing, the host.
So everything except the host is there or job.
OK, so if you want that.
I don't want to be there.
OK.
Update.
So we'll look at that so low key times.
There we go.
OK, another one dashboard settings variables we could do one for host in Loki.
That's a query.
Loki host Loki.
The query is labor values host California.
My school, my Loki has two prom tails pushing down it to it, and those tails are on the Gryffindor
muscular server so that we're going to update that to save my progress.
Okay, look at it.
Loki hosts Gryffindor Moscow team.
We do the same with job losses going of Prometheus, query the queries of very similar dashboard variables.
New, I'm going to call this from names query.
Prometheus names, it's going to use Prometheus the query.
Label names.
They would go.
There are many of them.
I can update that or save the dashboard, look at it.
Prometheus names that list that comes from before explore and look at the Prometheus data source metric
browser.
These are all the prom names there, so going back into the dashboard, the variables added variables.
I can exclude that first one on the school name there.
I go, sir.
All right, good update.
Another Prometheus, this one will be prom job about label values job.
Came from Job one label.
Prometheus level values job, so all the jobs that I've set up in Prometheus, my Prometheus, not exporters,
I have various jobs.
Bafana Knight Prometheus update.
All right, good.
Let's have a look at Prometheus Jobs Callisto, another one now that we're more sophisticated prom host.
The variable dropdown will update depending on whatever the value of prom job is.
So from that one just there?
So let's copy that.
We use that from host, I'm going to call it.
OK, so variables, new host, it will be Prometheus.
That's the query.
And it's using prom job from the last variable I credit, which is called prom job.
But look at the dollar sign in front of a lot that to indicate that it's a variable and it's show me
influx DB mice will and Gravano.
So if I update that, OK, well before I'll do the Prometheus posts, I update, Hey, let's do that
now cause a node is selected.
I have not exporter's on the service in flux.
DB mice cool griffon.
OK, so if I select Gravano, I don't have any of those other servers with Agraféna.
Job on it with Prometheus.
I don't have any of those other servers with a permit.
His job on it.
But if I had node.
These are the three servers that I have a node job on.
So that's a variable that changes depending on the value of another variable.
Hey, I'm going to say that, OK, let's look at influx DB queries now.
This is influx DB version two, which if you're familiar with influx DB one, the queries were much
simpler than that influx.
DB two is quite a lot more complicated to use.
But anyway, here's some examples that you can refer to a copy that code source.
OK, so let's create a new variable to query one call source.
In flux, Deb, that's looking at the influx to be a source that we credit early on in the course,
and that is a simple query and broke credit the bucket code Telegraph with S&P measurements.
So if I click out of that preview the values Carafano, MySchool, an influx DB, these are the service
where I store this in a big Damon's set up telegraph to query those.
So it's quite a more complicated query update.
Let's have a look at that source.
Bafana High School in Flux DB we can modify that name to be in flux DB source.
This was informative update to complexity, but a source close to another influx, Debbie.
Variables new, this one will be interface, but if we look at this, it's using the source variable
that is a here.
So copy that interface is called so interface, it's a query.
And Fox TV in a face, this is my astonished interfaces.
Flux to be there we go, and it's using the source from before I click out most of those servers that
I'm getting from digital, I should have two interfaces low in a Red Hat device.
One update that I go by look at that I go low.
It's also a dynamic variable because it's using the source variable here.
So if I change it to my key will also sync Docker because I have installed Docker on my MySchool server
as well.
Flux DB, I need to like that.
So that's another example of a dynamic variable based on the value of another Wrobel.
Let's save that and look at another one, Xbox.
If you set up the Xbox data sources, variables new Xbox One, click out of that.
It's showing me Linux Xbox service.
That's the first query, but I'm going to stick to type being host with the group being that and the
host also being that.
It's now show me all the hosts I have set up in Xbox, those down there.
I'm going to call that host the very what I I'm or exists or Xbox hosts.
I'm using Camel Case, the query service host and site that so will look at it on my Xbox hosts so I
could have dynamic tables and graphs stats based on whichever one I click.
And finally, would you want for ElasticSearch as well?
We'll look at the metric beat data source and we'll find everything to do with System D unit.
So variables you want to call it unit.
Query ElasticSearch metric beat system D unit sets finding terms with the field system D unit so we
could have many of those, such as host dot name and there's one of uninstalled ElasticSearch metric
pain, one of my servers.
But let's go back to System D, you know this is a lot more information need.
Look at Shamal so we can look at information about Docker servers if we had it.
Cron log rotate update that.
Very good.
Let's look at the dashboard and we have one for unit and that information is coming from our ElasticSearch.
Fields.
Excellent.
So there are a whole lot of examples there.
The different data sources in the dashboard variables section.
The best way to know how to create these is to look at other examples of dashboards and reverse engineer
them.
There's no real easy way to know exactly what you should write.
Here is a trial and error process.
I've taught myself how to do all these, basically just looking at how other people have done it.
So you guys have a lot of examples anyway in the next few videos will actually start using these.
But more specifically, I'll be focusing on the Prometheus dashboard.
Variables will be creating our own Prometheus dashboard that dynamically updates based on which dashboard
variables we are selecting.
Excellent.