Template variables allow you to dynamically apply specific metric or log values to one or more widgets in each dashboard.
To create your first template variable in the dashboard, click Add Template Variables. If template variables are already defined, click on the -pencil- icon to open the template variable editor. Once in edit mode, click on Add Variable + to add another template variable.
A template variable is defined by:
Tag or Attribute:
Default Value: The default value for your template variable tag or attribute.
Once created, notice that you have statistics upon your template variables usage in your graphs. In the picture below, the template variable is not used in both graph of the dashboard:
Decide if you want to remove/add this template variable to all of your graph widgets with the respective Remove From All and Add to All buttons.
Template variables work with log and APM query based widgets because metrics, logs, and APM share the same tags.
Additionally, you can define log or APM template variables based on log or APM facets. These template variables start with
Note: Using the
Add to all button adds the template variable to all log/APM widgets.
To the left of the template variables on a dashboard, there is a dropdown listed as (Default Value). When you make a change to a template variable value, the value is not automatically saved to a view. To save the current values of the template variables in a view, click on the dropdown menu and click Save selections as view. From there, you are prompted to enter a unique name for the view. After saving, this view is listed in the dropdown menu. Click on this view to retrieve the previously saved values for the template variables.
To delete a view, click on the saved views dropdown and choose Manage views…. From there, a popup with your saved views is displayed with a trash bin icon next to each view. Click the appropriate trash bin icon to delete a view.
To modify the (Default Value) view, click on the pencil icon and update the template variable values. Then click Done to save.
If any values in the other views are changed, save the values as a new view, and then delete the original view.
Once you have defined a template variable, it appears in the options displayed in the
After the graph is saved, the value of this template variable is the one selected on top of your dashboard:
Even if the note widget doesn’t contain any graphs, you can display:
For instance, with the following note widget configuration:
dev value for the
$env template variable outputs the following result:
The event overlay search allows you to correlate metrics and events. Use template variables to find events that share certain tags with the metrics in your dashboard. The event overlay search is applied through an individual graph.
Values from dashboard template variables can be directly captured by using the
$<TEMPLATE_VARIABLE_KEY>.value syntax in the event search field.
Note: Dashboard template variables must be metric tags; event-supplied tags cannot be used as dashboard template variables.
For example, to search for events in the event stream with the same region tag, use:
In the following example, the template variable resolves to
tags:region:ap-south-1. After those events are brought up in the event search overlay, the timing of the events are marked by pink bars in the graphs to show the timing of events:
Use multiple template variables in the search field to display all corresponding events tagged. The following example uses the query
$<TEMPLATE_VARIABLE_KEY>.value syntax to capture the resolved
key:value from a given template variable and use it with other filters.
Find below an example that uses the
env tags together with the
tag in the search term
Additional helpful documentation, links, and articles: