Datadog templates and variables
Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables. Grafana lists these variables in dropdown select boxes at the top of the dashboard to help you change the data displayed in your dashboard. Grafana refers to such variables as template variables.
For an introduction to templates and variables, see the following topics:
To add a new Datadog query variable, see Add a query variable. Use your Datadog data source as your data source. The following queries are available:
Query | Description |
---|---|
* | Fetches the list of available metrics |
tag | Returns all tag tags using the value tag |
[metric]:all-tags | Returns all tag values associated with a given metric name. For example, datadog.agent.running:all-tags would return all tags associated with the datadog.agent.running metric |
scope | Returns all scope tags using the value scope |
host | Returns all host tags |
device | Returns all device tags |
env | Returns all env tags |
region | Returns all region tags |
site | Returns all site tags |
status | Returns all status tags |
version | Returns all version tags |
For custom tag groups, enter the tag group name. For example, if your custom tag group name is subscription_name
, enter that name in the Query field.
After you create a variable, you can add it to your Datadog queries. For more information, see Variable syntax.
Ad hoc filters
The ad hoc filters variable ships with Grafana and can be used with all Datadog queries. Ad hoc filters allow you to retrieve all key-value pairs from tags, such as region:east
or region:west
, and uses them as query tags. To create this variable, complete the following steps:
- Open your dashboard and go to Dashboard settings.
- Click Variables under Settings in the sidebar menu.
- Click Add variable.
- Select the Ad-hoc filters variable type from the dropdown menu.
- Enter general options.
- Select
Datadog
as the data source.
Note
Ad-hoc filters are only supported with the metric query types query, raw query or arithmetic.
Ad hoc filters are one of the most complex and flexible variable options available. Instead of a regular list of variable options, this variable allows you to build a dashboard-wide ad hoc query. Filters you apply in this manner are applied to all panels on the dashboard.