Variable Queries¶
View variable queries are used to define the value range and data source of variables. They support configuring whether the value range follows the dashboard time widget, meeting different data filtering needs.
Value Range Control¶
The selectable values obtained by the query can be chosen to be affected by the dashboard time range or not:
| Mode | Description | Use Cases |
|---|---|---|
| Follow Dashboard | Filter data based on the dashboard time widget | View only recently active hosts to avoid historical garbage data |
| Do Not Follow Dashboard | List all historical data | Need full enumeration, such as all service names (services usually do not change frequently) |
Explanation of value ranges for variable queries from different data sources:
| Measurement | Tag | Default Value |
|---|---|---|
| SHOW_MEASUREMENT(); Time filtering is not supported; Value range: All measurements in the current workspace. |
SHOW_TAG_KEY(from=['Measurement Name']); Time filtering is not supported; Value range: Tags under the selected measurement in the current workspace. |
SHOW_TAG_VALUE(from=['Measurement Name'], keyin=['Tag Name']); Time filtering is not supported. |
| Class | Attribute/Tag | Default Value |
|---|---|---|
O::RE(.*):(DISTINCT_BY_COLLAPSE(class));Supports adding time filtering, follows dashboard time widget; Value range: All source values under the default index within the selected time. |
SHOW_OBJECT_FIELD('kubernetes_nodes'); Does not support adding time filtering; Value range: All fields under the object data in the current workspace. |
O::kubernetes_nodes:(DISTINCT_BY_COLLAPSE(namespace));Supports adding time filtering, follows dashboard time widget. |
| Class | Attribute/Tag | Default Value |
|---|---|---|
CO::RE(.*):(DISTINCT_BY_COLLAPSE(class));Supports adding time filtering, follows dashboard time widget Value range: All source values under the default index within the selected time. |
SHOW_CUSTOM_OBJECT_FIELD('class value'); Does not support adding time filtering; Value range: All fields under the Resource Catalog data in the current workspace |
CO::cdsmnl:(DISTINCT_BY_COLLAPSE(cds));Supports adding time filtering, follows dashboard time widget. |
| Log Source | Attribute | Default Value |
|---|---|---|
L::RE(.*):(DISTINCT_BY_COLLAPSE(source));Supports adding time filtering, follows dashboard time widget; Value range: All source values under the default index within the selected time. |
SHOW_LOGGING_FIELD(index='default'); Does not support adding time filtering; Value range: All fields under the log data in the current workspace. |
L::RE(.*):(DISTINCT_BY_COLLAPSE(trace_id));Supports adding time filtering, follows dashboard time widget. |
| Attribute | Default Value |
|---|---|
| SHOW_TRACING_FIELD(); Does not support adding time filtering; Value range: All fields under the tracing data in the current workspace. |
T::RE(.*):(DISTINCT_BY_COLLAPSE(resource));Supports adding time filtering, follows dashboard time widget. |
| Data Category | Attribute | Default Value |
|---|---|---|
R::RE(.*):(DISTINCT_BY_COLLAPSE(source));Supports adding time filtering, follows dashboard time widget; Value range: All source values under the default index within the selected time. |
SHOW_RUM_FIELD('source value'); Does not support adding time filtering; Value range: All fields under the RUM data in the current workspace. |
R::error:(DISTINCT_BY_COLLAPSE(province));Supports adding time filtering, follows dashboard time widget. |
Main Query Methods¶
View variables currently support five types of query methods. You can choose as needed:
| Query Method | Use Cases | Key Features |
|---|---|---|
| DQL Query | Query non-metric data such as logs, objects, traces | The only method supporting all data types, supports cascading queries |
| PromQL Query | Query only metric data and familiar with Prometheus | Syntax compatible with Prometheus ecosystem |
| Data Type Query | Quick point-and-click configuration without writing queries | Visual selection, zero code |
| External Data Source | Connect to external databases like MySQL | Use SQL queries directly |
| Custom | Only a few fixed options | Directly fill in, no database query |
DQL Query¶
Supports all data types including metrics, logs, infrastructure, objects, traces, RUM, etc. It is the most comprehensive in functionality.
Basic Syntax Structure¶
Example:
Time Range Specification¶
DQL supports directly specifying the time range in the statement, which takes precedence over the dashboard time widget:
| Syntax | Meaning |
|---|---|
[10m] |
Last 10 minutes |
[1h] |
Last 1 hour |
[1d] |
Last 1 day |
| Not written | Use dashboard time widget |
Example:
Show Function Query¶
Suitable for querying metric-related metadata information. Does not support time range.
Syntax Structure¶
| Syntax | Description |
|---|---|
show_measurement() |
Returns all measurements in the current workspace |
show_tag_key(from=["cpu"]) |
Returns tags under the measurement cpu in the current workspace |
show_tag_key(from=["cpu"],keyin=["host"]) |
Queries the list of host tag values for the measurement cpu in the current workspace |
Example:
# Query all measurements
SHOW METRIC_SET()
# Query all tags for a specified measurement
SHOW LABELS FROM M::cpu
PromQL Query¶
PromQL queries support manually writing query statements. By default, they use the time selected by the dashboard time widget to query and return data.
For information about PromQL queries, refer to Getting Started with PromQL.
Data Type Query¶
If you need quick configuration and don't want to write query statements, you can directly select the data type and choose filter conditions on the page.
Supported data types:
- Metrics
- Basic Objects (hosts, containers, processes, etc.)
- Resource Catalog
- Logs
- APM
- RUM
In this mode, you cannot add time ranges or configure cascading queries.
External Data Source¶
If your target query selectable values are stored in an external database (e.g., MySQL, PostgreSQL), you can choose this query method to directly connect to your existing data system.
- Select the data source;
- Enter the query statement;
- Select the sorting method.
For more details, refer to External Data Sources.
Custom Query¶
If your target selectable values are fixed and limited in number, and you don't need to query the database, you can directly define a set of values for the view variable. Separate each option with an English comma ,, e.g., prod,test,dev,staging.
This query method does not support adding time ranges or configuring cascading queries.
Cascading Query¶
Used when multiple variables have a hierarchical relationship. For example:
- After selecting "service", the "environment" dropdown only shows environments for that service (not all environments).
- After selecting "environment", the "version" dropdown only shows versions for that environment.
Configuration Conditions¶
- Only DQL queries support cascading configuration;
- In the child variable's query statement, reference the parent variable's current value using
#{parent_variable_name}.
Configuration Example¶
The following uses the cascading filter of view variables in the Web Application Overview of RUM as an example to illustrate the configuration of linkage queries based on service, environment, and version:
Three variable query statements need to be configured in the dashboard. The second and third query statements use #{variable_name} configured in the first query:
- Variable 1 (Service): Query all application lists:
- Variable 2 (Environment): Query all application lists, and the environment list selected in Variable 1:
- Variable 3 (Version): Query all application lists, and the version list selected in Variable 2:
Query Scenario Examples¶
Associating Charts¶
-
In the chart query, when filtering fields, select the variable for the
value; -
Switch the variable value in the scenario view, and the chart will be filtered and displayed based on the variable tag.
Chart Reverse Addition¶
Prerequisite
The corresponding DQL filter contains a by grouping condition.
- After clicking on a specific time series or data point in the chart;
- Select Apply to View Variable;
- The system automatically fills in the query.




