Templates and variables
Template variables allow you to create dynamic, reusable dashboards. Instead of hard-coding values like metric names or host names, you can use variables that users can change from a drop-down menu.
Supported variable types
The Dynatrace plugin provides data source support for the following Grafana variable types:
Note
You can also use Grafana’s built-in variable types (Custom, Text box, Constant, Interval) with Dynatrace queries. These variables are defined manually and are not populated from Dynatrace. For more information, refer to Variable types.
Query variables
Query variables dynamically fetch values from your Dynatrace environment. To add a new Dynatrace query variable, refer to Add a query variable.
When creating a query variable, select your Dynatrace data source and choose from the following query types:
Regex - (Optional) Filter out any of the returned values from your query with a regular expression.
Note
Multi-valueandInclude All optionsupport varies by query type. Test your specific use case to verify compatibility.
Ad-hoc filters
Ad-hoc filters let users add filters to all metric queries on a dashboard without editing each panel. The Dynatrace plugin populates filter options from your Dynatrace entity types (such as Host, Process, or Service).
To create an ad-hoc filter variable:
- Go to Dashboard settings > Variables > New variable.
- Select Ad hoc filters as the variable type.
- Select your Dynatrace data source.
- Click Apply.
Once configured, a filter bar appears at the top of your dashboard. Users can add filters by selecting an entity type (key) and a specific entity (value). These filters automatically apply to all metric queries on the dashboard.
Variable syntax
The Dynatrace plugin supports multiple variable syntax formats:
Where to use variables
You can use template variables in the following query fields:
Chaining variables
A common pattern is to chain “Filter keys” and “Filter values for key” variables together. This allows users to first select a dimension (like Host or Process), then select a specific value for that dimension.
To chain variables:
- Create a variable using Filter keys query type. Name it something like
filterKey. - Create a second variable using Filter values for key query type.
- In the Filter key name field, enter
$filterKey.
Now the second variable’s options dynamically update based on the first variable’s selection.
Additional resources
For more information about variables in Grafana, refer to Templates and variables.



