New announcements for Serverless, Network, RUM, and more from Dash! New announcements from Dash!

Template Variables

Template variables allow you to dynamically apply specific metric or log values to one or more widgets in each dashboard.

Add a Template Variable

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:

  • Name: The value of your template variable displayed in your graph query.
  • 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 with logs and APM queries

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.

Template variable saved views

Creating a saved view of template variables

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.

Delete a saved view

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.

Modify a saved 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.

Use Template Variables


Once you have defined a template variable, it appears in the options displayed in the from field:

After the graph is saved, the value of this template variable is the one selected on top of your dashboard:

Note widget

Even if the note widget doesn’t contain any graphs, you can display:

  • The selected template variable with the $<TEMPLATE_VARIABLE_KEY> syntax.
  • The selected template variable value in it with the $<TEMPLATE_VARIABLE_KEY>.value syntax.

For instance, with the following note widget configuration:



Selecting the dev value for the $env template variable outputs the following result:

Events Overlay

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.

Single Template variable

For example, to search for events in the event stream with the same region tag, use: tags:region:$region.value.

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:

Multiple Template variables

Use multiple template variables in the search field to display all corresponding events tagged. The following example uses the query tags:role:$role.value,env:$env.value

Associating Template variables with other Tags

Use the $<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 hosts tag in the search term tags:env:$env.value hosts:$host.value

Further Reading