Template Variables
This document was translated by ChatGPT
#1. Template Variables
Template variables allow you to define a set of variables in the current Dashboard, which can be referenced in chart search conditions. By quickly changing the values of these variables, you can update the search conditions of charts without having to create multiple identical visualization Panels just because the search conditions differ.
#1.1 Managing Template Variables
You can manage template variables centrally through the Template Variable List.
As shown below, in the template variable list, you can ① Add, ② Delete, and ③ Edit variables. You can also enter any string in the ⑤ Search Bar, and adjust the column width display in ④ Settings, such as evenly distributing column widths or adjusting them based on content.

00-Template Variable List
#1.2 Creating a New Template Variable
When you need to build quick search conditions for the current Dashboard, you can create a new template variable to achieve this.
For example: When building an Application Observability Dashboard, if you need to quickly view different applications, you can create a template variable for the application search condition.
Step 1: On the Dashboard details page, click the ① Settings button and select ② Manage Template Variables.

01-Step 1
Step 2: In the template variable list pop-up, click the ③ New Template Variable button.

02-Step 2
Step 3: Create the template variable as needed. The DeepFlow platform provides three types of template variables: Dropdown Selection, Text Input, and Group. Detailed descriptions are provided in the following sections.

03-Step 3
#1.2.1 Dropdown Selection
A dropdown selection type template variable changes the search condition via a dropdown menu.
Currently, this type supports building template variables for resource and xx_enum type Tags in the DeepFlow platform database.
- Note: For a description of the DeepFlow platform database, see later sections.

04-Dropdown Selection
- ① Query Type: Different query types pass values differently
- Query by ID: Supports passing IDs for queries
- Query by Name: Supports passing strings for queries
- ② Value Range: Supports two ways to set template variable values:
Static ValuesandDynamic Values- Static Values: Fixed value range after being referenced
- Dynamic Values: Compared to static values, the range can be affected by
Static ValuesorValue Tag. For details, see the Creation and Reference section
- ③ Data Source: Specifies the data table where the template variable values come from
- ④ Value Tag: Specifies the Tag corresponding to the template variable values
- ⑤ Value Range: Selects the values corresponding to the template variable
- ⑥ Selection Mode: Changes the search condition via a dropdown menu, single-select by default
- Multi-select: Check
Multi-selectto enable multi-selection mode - Select All: Check
Select Allto add aSelect Alloption in the dropdown, selecting all values for the template variable
- Multi-select: Check
- How to reference: When adding a query condition in the chart search bar, enter the Tag. Any existing template variable with the same
Tagwill appear as a dropdown option. For details, see the Creation and Reference section.
#1.2.1.1 Creation and Reference
The following demonstrates how to create and reference static template variables and dynamic template variables, and how to link dynamic and static template variables.
- First, create a static template variable named
K8s Namespacewith Tagpod_ns, and set its value range todeepflow-ebpf-istio-demo, deepflow-otel-grpc-demo, deepflow-telegraf-demo.

05-Create Static Template Variable
- Next, create a dynamic template variable named
K8s Workloadwith Tagpod_group, and set its value range topod_ns = K8s Namespace. This means the dropdown options forpod_groupwill change based on the selection ofpod_ns.

06-Create Dynamic Template Variable
- Then, select the query condition
pod_group = K8s Workloadto reference the template variable in the chart search conditions.

07-Template Variable Reference
- Finally, you can quickly switch the referenced template variables at the top of the Dashboard. Different selections for
K8s Namespacewill result in different options forK8s Workload.

08-Using Template Variables

09-Switch Template Variables
#1.2.2 Text Input
A text input type template variable changes the search condition by entering a string.

10-Text Input
Text input type template variables can be referenced by any Tag or operator that allows direct input.
In search conditions, they appear similar to Dropdown Selection type template variables.
- ① Tag Reference: Supports int, int_enum, string, ip, and mac types. All these Tag types support all operators.

11-Tag Reference
- ② Operator Reference: Supports :, !:, =~, and !~ operators. All these operators support all Tag types.

12-Operator Reference
#1.2.3 Group
A group type template variable changes the grouping via a dropdown menu.
For example, when drilling down into data from K8s Cluster -> K8s Namespace -> K8s Service -> K8s Workload -> K8s POD, you can create this type of template variable.

13-Group
- Value Range: All
Tagsin the DeepFlow platform database can be used as values for this type of template variable- ①: Specifies the data table where the template variable values come from
- ②: Selects the values corresponding to the template variable
- Selection Mode: For details, see the description of the Dropdown Selection type template variable
- Note: The main group cannot reference template variables in
Multi-selectorSelect Allmode
- Note: The main group cannot reference template variables in
Group type template variables can only be referenced in the grouping section of search conditions. They appear as dropdown options in the grouping menu.

14-Group Reference