Skip to content

Variable Query


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 queried by the variable based on the time range selected by the dashboard's Time Widget;
  • Do not follow the dashboard linkage, that is, list all the data queried by the variable, regardless of the time range selected by the dashboard's Time Widget.

Explanation of the value range for variable queries from different data sources:

Source Measurement Tag Default Value
Metrics 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.
Source Class Attribute/Tag Default Value
Basic Objects O::RE(.*):(DISTINCT_BY_COLLAPSE(class));
Supports time filtering, follows the dashboard Time Widget linkage
Value range: All source values under the default index within the selected time range.
SHOW_OBJECT_FIELD('kubernetes_nodes');
Time filtering is not supported;
Value range: All fields under the object data in the current workspace.
O::kubernetes_nodes:(DISTINCT_BY_COLLAPSE(namespace));
Supports time filtering, follows the dashboard Time Widget linkage.
Source Class Attribute/Tag Default Value
Resource Catalog CO::RE(.*):(DISTINCT_BY_COLLAPSE(class));
Supports time filtering, follows the dashboard Time Widget linkage
Value range: All source values under the default index within the selected time range.
SHOW_CUSTOM_OBJECT_FIELD('Class Value');
Time filtering is not supported;
Value range: All fields under the Resource Catalog data in the current workspace
CO::cdsmnl:(DISTINCT_BY_COLLAPSE(cds));
Supports time filtering, follows the dashboard Time Widget linkage.
Source Log Source Attribute Default Value
Logs L::RE(.*):(DISTINCT_BY_COLLAPSE(source));
Supports time filtering, follows the dashboard Time Widget linkage
Value range: All source values under the default index within the selected time range.
SHOW_LOGGING_FIELD(index='default');
Time filtering is not supported;
Value range: All fields under the log data in the current workspace.
L::RE(.*):(DISTINCT_BY_COLLAPSE(trace_id));
Supports time filtering, follows the dashboard Time Widget linkage.
Source Attribute Default Value
APM SHOW_TRACING_FIELD();
Time filtering is not supported;
Value range: All fields under the tracing data in the current workspace.
T::RE(.*):(DISTINCT_BY_COLLAPSE(resource));
Supports time filtering, follows the dashboard Time Widget linkage.
Source Data Class Attribute Default Value
RUM R::RE(.*):(DISTINCT_BY_COLLAPSE(source));
Supports time filtering, follows the dashboard Time Widget linkage
Value range: All source values under the default index within the selected time range.
SHOW_RUM_FIELD('Source Value');
Time filtering is not supported;
Value range: All fields under the RUM data in the current workspace.
R::error:(DISTINCT_BY_COLLAPSE(province));
Supports time filtering, follows the dashboard Time Widget linkage.
Source Attribute Default Value
Security Check SHOW_SECURITY_FIELD();
Time filtering is not supported;
Value range: All fields under the Security Check data in the current workspace.
S::RE(.*):(DISTINCT_BY_COLLAPSE(rule));
Supports time filtering, follows the dashboard Time Widget linkage.

DQL Query

DQL query supports manual statement writing, allows setting time ranges, and enables Cascade Query, returning the required data instantly.

Click Learn more about DQL definitions and syntax.

Query Example:

Note

It is recommended to use this method for non-metric data such as infrastructure and logs.

Syntax
Description
Data Type::Data Source:(distinct('Attribute Field Name')){Filter Conditions} M/metric - Time Series Metrics
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 list of app_id for Web RUM
R::view:(distinct(env)){app_id = '8f05003ebccad062'} Returns the list of env for Web RUM with 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 list of env corresponding to the selected app_id

Adding Time Range

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

  • If a time range is added in the DQL query, the time range in the DQL query is prioritized;
  • If no time range is added in the DQL query, the time range selected by the dashboard's Time Widget is 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 filters.

Click Learn more about DQL functions.

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 measurement cpu in the current workspace
show_tag_key(from=["cpu"],keyin=["host"]) Queries the list of host tag values under the measurement cpu in the current workspace

PromQL Query

PromQL query supports manual query statement writing, uses the time selected by the dashboard's Time Widget by default for querying, and returns the data.

For more information about PromQL queries, refer to PromQL Quick Start.

Data Type Query

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

In this mode, time ranges cannot be added, and Cascade Query cannot be configured.

External Data Source

Integrate multiple external data sources such as MySQL, directly call native query statements, and retrieve data in real time.

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

For more details, refer to External Data Source.

Custom Query

Directly define a set of values for view variables, without the need to obtain values through query statements. Each option is separated by an English comma ,. This query method does not support adding time ranges or configuring cascade queries.

Cascade Query

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

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 example illustrates the configuration of cascade query for view variables in the Web Application Overview of RUM, based on service, environment, and version for linkage query:

Three variable query statements need to be configured 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 Cases

Link view variables with charts to implement linkage filtering

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

  2. Switch the variable value in the scene view, and the chart will be filtered and displayed based on the variable label.

Reverse addition to charts to implement 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.

Feedback

Is this page helpful? ×