kind and query), when it fires (condition_cel), when it resolves, and how long each must hold. This page is the reference for those fields. For the concepts behind them, see Alarms overview. For a guided first rule, see the first alarm walkthrough.
Kinds
Setkind on the definition. An empty kind is treated as event.
condition_cel is required by the API for every kind. For an event rule with a query and for a staleness rule, the evaluator never runs it. Send "true" — the Console does the same.Threshold
A threshold rule runs its SQL every evaluation interval against the dataspace’s read view. Each row the query returns is evaluated on its own:- The row’s columns are exposed to CEL as
event.<column>. condition_celdecides whether that row is breaching.- The values of the
labels_bycolumns identify which alarm instance the row belongs to.
GROUP BY device_id, and labels_by: ["device_id"].
A column named value is special: when present and numeric, it is recorded as the instance’s trigger value and is what the deadband compares against.
Event
An event rule works in one of two ways, depending on whether it has a query.- With a query
- Without a query
The rule runs
query_spec.sql every evaluation interval. If the query returns at least one row, the condition is met. If it returns no rows, the condition is not met. CEL is not evaluated on the result.There is one instance for the definition’s asset_id, or a single project-wide instance when asset_id is empty. Use this when “any row matches” is the alarm — for example any error-level log line in the last five minutes.Staleness (device offline)
A staleness rule fires for each device that has been disconnected longer thanstaleness_window_seconds.
Query spec
query_spec carries the native SQL a threshold rule (or an event rule with a query) runs:
Name the read view in
FROM, not the dataspace name. Copy it from the dataspace catalog’s read_view field (it looks like ds_read_<hex>). The Console shows it above the SQL editor. See Dataspaces overview.
Query limits
Every scheduled query must stay small, because rules share one evaluator. When you create or update a definition, the SQL is checked and rejected if it breaks any of these rules:
Accepted window forms:
CEL expressions
condition_cel, resolve_cel, and clear_cel are CEL expressions. Each must evaluate to a boolean, or the definition fails to evaluate.
The CEL math and strings extensions are available.
Examples:
Deciding when an alarm resolves
The resolve candidate is chosen in this order:resolve_cel— if set, the alarm starts resolving when this is true. Use it for an asymmetric band: fire atevent.value > 80.0, resolve atevent.value < 70.0.clear_cel— if set (andresolve_celis not), the alarm starts resolving when this is true.deadband— if neither expression is set, and bothdeadbandand asetpointinmetadataare greater than zero, the alarm starts resolving when the row’svalueis at or belowsetpoint - deadband.- Otherwise — the alarm starts resolving when
condition_celis false.
resolve_cel, clear_cel, and deadband apply to threshold rules and to event rules without a query. Scheduled event rules resolve when the query returns no rows. staleness rules resolve when the device reconnects.
Timing and hysteresis
Hold times are measured from the instance’s own timestamps, so they survive restarts. On scheduled rules a hold can only mature on an evaluation, so the effective delay rounds up to the next evaluation.
If the condition goes false while an instance is still
pending, the instance closes without ever firing. A resolved instance that breaches again fires again immediately — for_seconds gates only fresh activations.No data handling
on_no_data decides what happens to an open instance when its labelset produces no row on a threshold evaluation, or when its row is deleted on an event rule without a query.
No data only affects labelsets that already have an open instance. A labelset that has never produced a row cannot raise an alarm through
alert. Scheduled event rules and staleness rules always have data and ignore this field.
Labels
labels_by lists the result columns whose values identify an instance on a threshold rule. Rows with the same values for those columns update the same instance; a new combination opens a new one. The values are stored on the instance as its labels and shown on the board.
Every column in
labels_by should appear in the query’s SELECT.
Scoping to assets
staleness rules always cover every enabled MQTT device in the project.
Examples
POST /projects/{project_id}/alarm-definitions — see API reference.
Telemetry stops arriving
For devices that have no broker connection, alarm on silence with athreshold rule. This is the query the Console’s Telemetry stops arriving template generates for a 20-minute window:
condition_cel: "true", labels_by: ["device_id"], and on_no_data: "resolve". A device appears in the result only while it is quiet, so it resolves as soon as rows resume.
Next steps
Notifications
Get paged when an instance fires, with re-notify and escalation.
Silences and shelving
Suppress alarms during maintenance or known faults.
Console guide
Author definitions in Alarms → Definitions.
Troubleshooting
Rules that never fire, rejected queries, and flapping alarms.