Skip to main content
Monitors retrieves data through SLS SQL queries and triggers alerts based on query results.

Core concepts

Threshold evaluation mode

This mode is suitable for scenarios requiring threshold comparison on aggregated values.

Configuration

  1. Query Statement: Write SLS SQL aggregate query.
    • Example: Count error log quantity by host in the last 15 minutes.
  2. Query Parameters:
    • sls.project: (Required) Project name.
    • sls.logstore: (Required) Logstore name.
    • sls.timespan.value: (Optional) Time span value, default is 15.
    • sls.timespan.unit: (Optional) Time span unit, supports s (seconds), m (minutes), h (hours), d (days). Default is m.
  3. Field Mapping:
    • Value fields: Select error_cnt for threshold evaluation.
    • Label fields: Select host to identify the alert object. After you select label fields, other non-value fields are carried with the alert as additional information.
    • See Query result field mapping for the complete behavior.
  4. Threshold Conditions:
    • Use $A.field_name to reference values.
    • Example: Critical: $A.error_cnt > 50, Warning: $A.error_cnt > 10.

How it works

Monitors runs the SLS query for the configured time range, distinguishes alert objects by their label fields, and evaluates thresholds with their value fields. If Label fields is empty, every returned field except the value fields becomes a label.

Recovery logic

See Alert recovery for the recovery options. A recovery query is a separate SQL statement; it supports ${label_name} variables and Go templates such as {{ $labels.<label_name> }} (alert engine v0.75.4 or later).

Data exists mode

This mode is suitable for scenarios where filter logic is written directly in SQL.

Configuration

  1. Query Statement: Use HAVING clause to filter anomalous data.
    • Example: Query hosts with error count exceeding 50.
  2. Query Parameters: Same as above, need to configure sls.project and sls.logstore.
  3. Evaluation Rules: As long as query returns data, triggers alert.
Data exists mode cannot distinguish alert levels; use threshold evaluation when you need levels.

Recovery logic

See Alert recovery for the recovery options.

No data mode

This mode is used to monitor scenarios where “data is expected but actually missing”. SLS offers two no-data conditions; enable either one, or both as you need: Among log-service data sources only Tencent Cloud CLS lacks the per-series condition; see Tencent Cloud CLS.

Configuration

  1. Query Statement: Write a query that is expected to continuously return data.
    • Example: Query log reporting heartbeat from all hosts.
  2. Evaluation Rules: Enable a condition from the table above. With “Alert when all queries return no data”, N comes from the Trigger condition shared by the tab; with “Alert if previously found data is now missing”, each series is evaluated on its own and you can also set the recovery mode from the table.

Recovery logic

The recovery mode of “Alert when all queries return no data” is not configurable. It is fixed to recover automatically once any query returns data again and shown as read-only text.

Advanced configuration

If you need to use SLS enhanced SQL syntax, add in query parameters: sls.powersql: true
Default queries data from the last 15 minutes. Adjustable through parameters:
Do not use __time__ for filtering in SQL; the engine automatically sets time range based on parameters.
In raw log search mode, sls.lines controls the maximum number of log rows returned by a single query. Each returned row can produce one alert.Applies to raw log search only. Aliyun ignores this setting when the query contains SQL.
For debugging only; do not configure in production rules: