Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Documentationbreadcrumb arrow Pluginsbreadcrumb arrow Datadog data sourcebreadcrumb arrow Datadog templates and variables

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:

QueryDescription
*Fetches the list of available metrics
tagReturns all tag tags using the value tag
scopeReturns all scope tags using the value scope
hostReturns all host tags
deviceReturns all device tags
envReturns all env tags
regionReturns all region tags
siteReturns all site tags
statusReturns all status tags
versionReturns 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:

  1. Open your dashboard and go to Dashboard settings.
  2. Click Variables under Settings in the sidebar menu.
  3. Click Add variable.
  4. Select the Ad-hoc filters variable type from the dropdown menu.
  5. Enter general options.
  6. 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.