Skip to content

Alert rules API

Alert rules and the alerts they raise (T202, features.alert_rules). alert_rules:read lists alerts and rules, alert_rules:manage changes them; both cover the session’s own teams and organization, and every team, every organization and the global rules only with alert_rules:global (admin, and read-only viewer and operator).

GET /api/v1/admin/alerts · operation listAlerts

Alerts newest first (by last_seen_at), with the counts by state of everything the session may see. Requires alert_rules and alert_rules:read. A session sees the team alerts of its teams and the organization alerts of the organization it administers; global alerts and every other team need alert_rules:global. The scope is applied before counts, filters and pages.

Authentication: adminSession

Parameters

Name In Type Description
state query string Comma-separated states to keep: open, acknowledged, resolved. Empty is every state.
severity query string Comma-separated severities to keep: info, warning, critical.
source query string, pattern ^[a-z][a-z0-9_]{0,31}$ Only the alerts one raiser raised: rule, or a feature’s own name such as topics, insights or evaluation_monitor
rule_id query string, max length 128
team query string One team. A filter never widens the session’s scope.
organization query string
scope query string, one of "global", "organization", "team"
q query string, max length 100 Case-insensitive text in the title, the rule name or the group.
limit query integer, default 50, min 1, max 200
cursor query string next_cursor of the previous page.

Responses

Status Description Body
200 Page of alerts application/json: object
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

Response 200 fields:

  • application/json: object
    • data (array of Alert, required)
    • can_manage (array of boolean, required) — Per alert of data: whether this session may acknowledge, resolve and mute it.
    • next_cursor (string)
    • counts (object, required)
      • open (integer (int64), required)
      • acknowledged (integer (int64), required)
      • resolved (integer (int64), required)

GET /api/v1/admin/alerts/{id} · operation getAlert

One alert. An alert outside the session’s scope answers 404, exactly as a missing one.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required

Responses

Status Description Body
200 The alert application/json: object
403 Model not allowed application/json: Error
404 Alert not found, outside the session’s scope, or feature disabled —

Response 200 fields:

  • application/json: object
    • alert (Alert, required)
    • can_manage (boolean, required)

POST /api/v1/admin/alerts/{id}/{action} · operation changeAlert

Acknowledge an open alert, resolve an active one (a notified alert sends a resolved message to the rule’s channels), mute its notifications for a duration or end the mute. Requires alert_rules:manage over the alert’s team or organization (alert_rules:global for a global alert); outside it the answer is 404. Each action is audited (alert.acknowledge, alert.resolve, alert.mute, alert.unmute).

Authentication: adminSession

Parameters

Name In Type Description
id path string, required
action path string, required, one of "acknowledge", "resolve", "mute", "unmute"
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • duration (string) — mute only: a Go duration from 1m to 720h.

Responses

Status Description Body
200 The alert after the action application/json: object
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Alert not found, outside the session’s scope, unknown action, or feature disabled —
409 invalid_state: the alert’s state does not allow the action —

Response 200 fields:

  • application/json: object
    • alert (Alert, required)
    • can_manage (boolean, required)

GET /api/v1/admin/alert-rules · operation listAlertRules

The alert rules the session may see (YAML rules read-only, stored rules with their version), each with its effective values and its last scan; the catalog of signals, fields, metrics and built-in rules; the scopes the session may write; and the channels it may attach, named only by the session’s own scopes. Requires alert_rules and alert_rules:read.

Authentication: adminSession

Responses

Status Description Body
200 Rules, catalog and write scope application/json: AlertRuleList
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

POST /api/v1/admin/alert-rules · operation createAlertRule

Create a stored rule. The gateway assigns the ID (ar_ and 20 hexadecimal characters); a body with an id is refused. Requires alert_rules:manage over the rule’s scope: a team the session administers, the organization it administers, or anything with alert_rules:global (403 scope_forbidden otherwise). Every channel must exist, carry the alert_rule event and be open to the scope (422, the same answer for a missing channel and one of another tenant). At most 50 stored rules per team, per organization and for the global scope, and 500 in all (409 rule_limit). Audited as alert_rule.create.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
201 The stored rule application/json: AlertRuleView
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
409 rule_limit —
422 invalid_alert_rule: the rule, its owner or one of its channels is invalid —

POST /api/v1/admin/alert-rules/preview · operation previewAlertRule

Backtest an unsaved rule: what it would have matched in the last 24 hours. It writes nothing and notifies no one. The rule passes the same checks as a create, so a session previews only inside the scope it may write. A realtime rule is counted per hour; a scheduled rule is evaluated on tumbling windows of its own window (at least five minutes, one window when it is 24 hours or longer), which approximates its sliding evaluation; a built-in rule is evaluated as of now. The scan runs on the engine the rule itself would read and is bounded to 30 seconds (504 scan_timeout).

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
200 The backtest application/json: AlertPreview
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
409 span_store_disabled: a span rule needs features.span_store —
422 invalid_alert_rule —
504 scan_timeout —

PUT /api/v1/admin/alert-rules/{id} · operation updateAlertRule

Replace a stored rule at its version (409 version_conflict). Its scope, organization and team never change (400). A rule outside the session’s scope answers 404; a YAML rule answers 409 yaml_owned to a session that can see it. A channel the rule already has may stay even when the editor could not add it. The next scan runs from now. Audited as alert_rule.update.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • version (integer (int64), required)
    • rule (AlertRule, required)

Responses

Status Description Body
200 The stored rule application/json: AlertRuleView
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Rule not found, outside the session’s scope, or feature disabled —
409 version_conflict or yaml_owned —
422 invalid_alert_rule —

DELETE /api/v1/admin/alert-rules/{id} · operation deleteAlertRule

Delete a stored rule at its version, with its schedule state. Its active alerts are resolved (resolved_by rule_deleted) and stay in the history. Audited as alert_rule.delete.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required
version query integer (int64), required, min 1 The rule’s current version, from the list; a stale one answers 409 version_conflict.
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Responses

Status Description Body
204 Deleted —
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Rule not found, outside the session’s scope, or feature disabled —
409 version_conflict —

POST /api/v1/admin/alert-rules/{id}/mute · operation muteAlertRule

Silence every notification of a rule for a duration, or end the mute with an empty duration. The rule keeps matching and its alerts keep being recorded. It applies to YAML rules too: a mute is operational state, not configuration. Audited as alert_rule.mute or alert_rule.unmute.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • duration (string) — A Go duration from 1m to 720h; empty ends the mute.

Responses

Status Description Body
200 The rule’s state application/json: object
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Rule not found, outside the session’s scope, or feature disabled —

Response 200 fields:

m7gtw[email protected]