How fields are classified
Suppose query A returns:
Recommended configuration:
Additional information is not a third set of fields that you configure. After you explicitly select label fields, every returned field that is neither a label nor a value automatically becomes additional information.
Value fields
A value field must contain data that can be converted to a number. Threshold evaluation requires at least one value field. Value fields are optional in Data exists and No data modes.- A value field name cannot be empty or contain
.. - The same field cannot be both a value field and a label field.
- Preview the query and use the returned field names. Saving a rule does not query the data source to verify that a returned field exists.
Label fields
Label fields define alert identity and determine whether results from different queries can be matched. Choose stable dimensions such as service, cluster, host, or instance.- A label field name cannot be empty, and the same field cannot be added more than once.
- The same field cannot be both a label field and a value field.
- Timestamps
- Raw log lines or error messages
- Trace IDs, request IDs, or other values that change per request
- Other high-cardinality fields
When Label fields is empty
For compatibility with existing rules, if Label fields is empty, every returned field except the value fields becomes a label. The query does not produce additional information in this case.
The SLS-provided
__source__ and __time__ fields do not automatically become labels when Label fields is empty. If you need either value, assign it an alias in the query and configure the alias as a regular field.
Referencing values in threshold expressions
The query name is the prefix of its threshold variables. For example, suppose query A has a value field namederror_count.
One value field
With one value field, you can use either the fully qualified form or the query variable shortcut:Multiple value fields
If query A has botherror_count and latency_ms as value fields, include the field name:
$A > 20 in this case. Every field referenced in the expression must also be configured as a value field for that query. The same rule applies to a custom recovery threshold expression.
Query names
A query name must begin with an English letter and contain only English letters and numbers, such asA, B2, or Latency. R and __all__ are reserved and cannot be used.
Matching multiple queries
In Threshold evaluation mode, results from queries A and B participate in the same evaluation only when their label names and label values match exactly. These results match:
You can evaluate them together:
cluster label, or its cluster value differs, the rows are not evaluated together. Make sure that:
- Each query uses the same label fields and returns the same label values.
- One label set identifies only one row in each query. Aggregate the query first if necessary.
- Changing values such as error messages and raw log content remain additional information rather than labels.
Using additional information in a description
Query-provided additional information is available through$annotations and always uses $<query name>.<field name> as its key. The syntax is the same regardless of the number of queries or whether you use Threshold evaluation, Data exists, or No data mode:
$ prefix identifies query-provided fields. A custom field configured on the rule cannot begin with $. See Description Template for more variables and examples.
A No data alert carries the additional information from the last successful result for that alert object. If the query has never returned data, no query-provided additional information is available.
Supported queries
This page applies to:- MySQL, PostgreSQL, Oracle, ClickHouse, Elasticsearch, and SLS queries
- Raw log primary queries for Loki and VictoriaLogs