Variables enable more interactive and dynamic dashboards. Instead of hard-coding things like server or sensor names in your metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard. Check out the Templating documentation for more information.
Datav's templating variables are almost the same as Grafana's, but there are differences, imagine that if multiple dashboards share a variable, how do you resolve this? So that's where Global variables are needed.
If you are already familiar with Grafana, then this part is almost the same as Grafana.
Add variable
url
,Type -> Values separated by comma
-> /user/login,/user/logout,/user/info`Add
, then return to dashboard pageAt this point, under the navigation bar, a 'URL' selection box appears and helps us automatically select '/user/login'. Next, use the 'URL' variable:
Apply Button
in the upper right corner to return to the dashboard pageAt this point, you should see that the title of the panel successfully uses the value of the current 'url' variable.
Because this is a local variable, it only takes effect on the current dashboard and is not visible when you switch to another dashboard
Now let's add a global variable 'app' to represent the currently selected application, since an application may have multiple dashboards, and these dashboards should share a same app variable, in grafana, we need create app
variable for each dashboardd, in datav, we can only do it once.
app
, Type -> custom
, Values separated by comma
-> sms,gateway,mysql
Add
, then return to dashboard pageTo verify the effect, first set app
to mysql
in the current global variable dashboard and then go to the dashboard we created earlier. You will see the select box for 'app' in the upper right corner with the value already set to
mysql
.
At this point, our beginner's guide is complete, you can find more comprehensive and detailed content in the advanced tutorial series.