Skip to content

Variable Queries


Query Methods

DQL Query

PromQL Query

Data Type Query

External Data Source

Custom

Value Range

There are two ways to determine the value range of view variables:

  • Follow the dashboard linkage, that is, list the data of the variable query according to the time range selected by the dashboard's time widget.
  • Do not follow the dashboard linkage, that is, list all the data of the variable query, regardless of the time range selected by the dashboard's time widget.

Description of the value range of 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 the dashboard time widget linkage
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 the dashboard time widget linkage.
Class Attribute/Tag Default Value
CO::RE(.*):(DISTINCT_BY_COLLAPSE(class));
Supports adding time filtering, follows the dashboard time widget linkage
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 the dashboard time widget linkage.
Log Source Attribute Default Value
L::RE(.*):(DISTINCT_BY_COLLAPSE(source));
Supports adding time filtering, follows the dashboard time widget linkage
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 the dashboard time widget linkage.
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 the dashboard time widget linkage.
Data Class Attribute Default Value
R::RE(.*):(DISTINCT_BY_COLLAPSE(source));
Supports adding time filtering, follows the dashboard time widget linkage
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 the dashboard time widget linkage.

DQL Query

DQL query supports manual statement writing, allows setting time range and enabling Cascade Query, and returns the required data immediately.

Click Learn more about DQL definitions and syntax.

Query Example:

Note

Infrastructure, logs and other non-metric data are recommended to use this method.

Syntax
Description
Data Type::Data Source:(distinct('Attribute Field Name')){Filter Conditions} M/metric - Time series metric data
O/object - Object data
L/logging - Log data
E/event - Event data
T/tracing - Tracing data
R/rum - RUM data
R::view:(distinct(app_id)) Returns the app_id list of Web RUM
R::view:(distinct(env)){app_id = '8f05003ebccad062'} Returns the env list corresponding to Web RUM app_id=8f05003ebccad062
R::view:(distinct(env)){app_id = #{appid}} Use #{Variable Name} in the DQL statement to implement Cascade Query: If the variable is named app_id in the previous step, it will automatically return the env list corresponding to the selected app_id

Add Time Range

When using DQL statements for view variable queries, you can add the data query time range in the format of [xx:xx:xx]:

  • If the time range is added in the DQL query, the time range in the DQL query will be used first.
  • If the time range is not added in the DQL query, the time range selected by the dashboard time widget will be used by default.

Query Example:

# Query the list of container hosts in the last 10 minutes 
O::docker_containers:(distinct(`host`)) [10m]

Show Function Query

When using DQL queries, you can use the Show function to query and return the corresponding data values. The Show function does not support adding time range filtering.

Click Learn more about DQL function descriptions.

Query Example:

Note

If metric data is enabled, it is recommended to use this query method.

Syntax Description
show_measurement() Returns all measurements in the current workspace
show_tag_key(from=["cpu"]) Returns the tags under the cpu measurement in the current workspace
show_tag_key(from=["cpu"],keyin=["host"]) Queries the host tag value list under the cpu measurement in the current workspace

PromQL Query

PromQL query supports manual query statement writing, uses the time selected by the dashboard time widget by default for query and returns data.

For PromQL query related information, refer to PromQL Quick Start.

Data Type Query

Supports selecting the following data sources: Metrics, Basic Objects, Resource Catalog, Logs, APM, RUM.

In this mode, you cannot add time range or configure Cascade Query.

External Data Source

Integrate MySQL and other external data sources, directly call native query statements, and obtain data in real time.

  1. Select the data source.
  2. Enter the query statement.
  3. Select the sorting method.

For more details, refer to External Data Source.

Custom Query

Directly define a set of values for view variables, without obtaining values through query statements. Each option is separated by an English comma ,. This query method does not support adding time range and configuring cascade query.

Cascade Query

When configuring multiple view variables and the second variable needs to be dynamically filtered based on the results of the first variable, the cascade query should be enabled.

Note

Cascade query only supports DQL statement query configuration.

Logical Operator Variable Value Matching Type Example
=
!=
Exact match, supports multiple selections. R::view:(distinct(env)) {app_id = '#{appid}'}
match(re)
not match(re)
wildcard
not wildcard
Fuzzy match, supports multiple selections. R::view:(distinct(env)) {app_id = re('#{appid}')}

The following takes the cascade query configuration of view variables in the Web Application Overview of RUM as an example, based on service, environment and version for linkage query:

You need to configure three variable query statements in the dashboard, and the second and third query statements use the #{Variable Name} configured in the first query:

  • Variable 1 (Service): Query all application lists:
T::re(`.*`):(distinct(service))
  • Variable 2 (Environment): Query all application lists, and the environment list selected in Variable 1:
T::re(`.*`):(distinct(env)) { service = '#{service}'}
  • Variable 3 (Version): Query all application lists, and the version list selected in Variable 2:
T::re(`.*`):(distinct(version)) {service = '#{service}'}

Use Case Examples

Associate view variables with charts to implement linkage filtering

  1. In the chart query, when filtering fields, select the variable in the value field.

  2. Switch the variable value in the scenario view, and the chart will be filtered and displayed according to the variable label.

Chart reverse addition to achieve global linkage

Prerequisite

The corresponding DQL filter has a by grouping condition.

  1. Click on a specific time series or data point in the chart.
  2. Select Apply to View Variable.
  3. The system automatically fills in the query.