Skip to content

Add groupby template variables options #30834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions content/en/dashboards/template_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

## Overview

Template variables allow you to dynamically filter one or more widgets in a dashboard. You can build saved views from your template variable selections to organize and navigate your visualizations through the dropdown selections.
Template variables allow you to dynamically filter or group widgets in a dashboard. You can build saved views from your template variable selections to organize and navigate your visualizations through the dropdown selections.

A template variable is defined by:

Expand All @@ -41,20 +41,28 @@
**Note**: If you do not see the tag or attribute you're looking for, it may be because that data hasn't been reported to Datadog recently. For more information, see [Historical Data][4].

## Add a template variable
If template variables are already defined, see [Edit a template variable](#edit-a-template-variable). If your dashboard does not have any template variables, you can click the question mark icon to open a help modal on how to use Dashboard Variables.

Check notice on line 44 in content/en/dashboards/template_variables.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.sentencelength

Suggestion: Try to keep your sentence length to 25 words or fewer.

{{< img src="/dashboards/template_variables/template_variable_menu.png" alt="Template variable menu showing the Configure Dropdown Values option" style="width:80%;" >}}

To add a template variable in a dashboard:
1. Click **Add Variables**.
1. If template variables are already defined, hover over the dashboard header and click the **Edit** button to enter edit mode.
1. In edit mode, click the **+ (plus)** icon to create a new template variable.
1. Click **Add Variable**.
1. You can add both **Filter** and **Group by** variable types.
1. Filter: Add a tag or attribute to filter dashboard queries and visualizations.
1. Group by: Add a tag or attribute to show a breakdown of groups within your data.
1. (Optional) After selecting a tag, click the **+ Configure Dropdown Values** button to rename the variable and set default or available values.
{{< img src="dashboards/template_variables/add_template_variable_configure_dropdown_values.png" alt="Add Variable popover showing the Configure Dropdown Values button" style="width:80%;" >}}
1. Click **Save**.
1. To add more template variables, see [Edit a template variable](#edit-a-template-variable)


## Edit a template variable

To edit a template variable in a dashboard:
1. Click the **Edit** button in the dashboard header.
To edit a template variable or add variables:
1. Hover over the dashboard header and click the **Edit** button.
1. In edit mode, click on a template variable and make changes in the popover.
1. To rearrange variables in the header, hover over a variable, then click and drag the drag icon handle.
1. Click the **+ (plus)** icon to add a new template variable.
1. (Optional) After selecting a tag, click the **+ Configure Dropdown Values** button to rename the variable and set default or available values.
{{< img src="dashboards/template_variables/edit_template_variable_drag.png" alt="Template variable edit mode popover showing the drag icon allowing you to rearrange the order" style="width:100%;" >}}

## Apply a template variable to widgets
Expand All @@ -75,31 +83,31 @@
### Create

1. Click on the **Saved Views** dropdown menu to the left of the template variables in your dashboard. When you update a template variable value, the value does not automatically save to a view.
1. To save your current template variables' values in a view, select **Save selections as view** from the **Saved Views** dropdown menu.
1. To save your current template variables' values in a view, select **Save selections as view** from the **Saved Views** dropdown menu.
1. Enter a unique name for the view with an optional description.
1. Click **Save**.
1. Click **Save**.

{{< img src="/dashboards/template_variables/saved_view_create.png" alt="Create saved views by selecting save selections as view" style="width:100%;" >}}

Your saved view appears in the dropdown menu. Click on the view to retrieve your previously saved template variable values.

### Delete

1. Click on the saved views dropdown menu and hover over the desired saved view.
1. Click on the saved views dropdown menu and hover over the desired saved view.
1. Click **Delete View**.

### Modify

The **Default view** can only be edited by changing the default values of the template variables. To edit the Default View:
1. Hover over the templates.
1. Click **Edit** when the button appears.
1. Click **Edit** when the button appears.
1. Click **Done** to save.

To modify template variables values for other saved views:
1. Select the desired saved view from the dropdown menu.
1. Edit the template variables to have the new desired models.
1. Open the dropdown menu again.
1. Click **Save Changes**.
1. Click **Save Changes**.

{{< img src="/dashboards/template_variables/saved_views_update_template_variable.png" alt="Modify the template variables of your saved views" style="width:100%;" >}}

Expand All @@ -111,7 +119,7 @@

## Usage

Template variables are used in widgets and event overlays.
Template variables are used in widgets and event overlays.

### Logs, APM, and RUM queries

Expand All @@ -123,7 +131,7 @@

### Widgets

When creating or editing a widget, existing template variables display as options in the `from` field. For example, if you configure the `environment` template variable, the `$environment` option is available as a dynamic variable in the widget.
When creating or editing a widget, existing filter template variables display as options in the `from` field, and existing group by template variables display as options following the `by` field. For example, if you configure the `environment` template variable, the `$environment` option is available as a dynamic variable in the widget.

Check notice on line 134 in content/en/dashboards/template_variables.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.sentencelength

Suggestion: Try to keep your sentence length to 25 words or fewer.

{{< img src="dashboards/template_variables/dynamic_template_variable.png" alt="Template variable can be set dynamically in widgets" style="width:100%;">}}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading