Introduction
You can implement variables in the DataSet Grafana integration. These are useful because they allow you to create more interactive and dynamic dashboards. Instead of hard-coding things like path, cluster, and host names within your dashboard queries, you can utilize defined parameters. This is similar to using substitution tokens within a DataSet dashboard. Variables are displayed as dropdown lists at the top of the dashboard.
Instructions
This guide expands upon the example dashboard that we configured in the Grafana Data Source Plugin article.
- Update dashboard settings - From the dashboard, click the configuration icon at the upper right
- On the "Settings" page, click the "Variables" link and the "Add Variable" button
- Set up a variable as follows:
- Specify a name for your variable --
logfile_list
was chosen for this example - Select the "Custom" type
- In the "Custom options -> Values separated by comma" field, add the values you wish to use, delimited by commas
- Select the "Include All" option if you want the graph to display combined results
- The "Custom all value" allows you to specify the values which are included. In this case, I used a value of
*
(the equivalent ofyour_parameter=*
within a DataSet search or graph query)
- Specify a name for your variable --
- Update the query associated with your dashboard panel(s):
- The
forlogfile
field now references the selected value of the Grafanalogfile_list
variable we just defined - The
forlogfile
field does not use a quote / double quote for its value, since:- We included the quotes within the
logfile_list
variable, and - No quotes are used with the
*
wildcard (ex.forlogfile=*
)
- We included the quotes within the
- The
- For general information on Grafana variables see the Grafana documentation
- Queries support all Grafana variable substitution syntaxes, for example:
$varname [[varname]] ${varname:option}
- For multi-value variables there is a custom default substitution method, the values will be quoted and separated with commas, for example:
"value1","value2","value3"
- The expected use of multi-value variables is for
in
queries, for example:serverHost=($host)
- Queries support all Grafana variable substitution syntaxes, for example:
Comments
0 comments
Please sign in to leave a comment.