Skip to content

Create an event rule

POST
/event-rules
curl --request POST \
--url https://example.com/api/v1/event-rules \
--header 'Content-Type: application/json' \
--data '{ "clear_criteria": { "expr": "example", "op": "eq", "value": "example" }, "clear_event_type": "example", "clear_sustain": "example", "description": "example", "enabled": true, "fire_criteria": { "expr": "example", "op": "eq", "value": "example" }, "fire_event_type": "example", "fire_sustain": "example", "label": "example", "message": "example", "name": "example", "sample_key": "example", "sample_window": "example", "selector": { "component_types": [ "example" ], "components": [ "example" ] }, "severity": "example" }'

Authors a rule that fires on each component it watches when its sample key meets the fire criteria for the fire sustain, and clears when the clear criteria (or the negation of fire) holds for the clear sustain. It names the event type it writes when it fires (required) and, optionally, when it clears; with a severity it also raises an alarm while it is firing, and without one it is informational. Criteria are expressions over the sample (value, key, instance, component.name, component.type) yielding true or false; a metric rule with a sample_window also reads window, the series’ points over that span, oldest first, so slope, growth and span can fire it on a sustained trend (criteria that read window need a sample_window, and a sample_window needs criteria that read it), and any metric rule may read age, how long the series has run in seconds (a process’s own key, since the process started), to hold a trend until a fill or a restart’s refill is past; a body may give {expr} or the short form {op, value}, and the answer is always {expr}. The key must be a registered property or metric, the criteria must compile against its lane (an unknown name or a result that is not a bool is a 422 naming the criteria, line and column), the event types registered and the severity, when given, a level that exists (else 422); a name already taken is a 409. Audited. Gated by rule:create, with an all-scope grant.

Media type application/json
object
$schema

A URL to the JSON Schema for this object.

string format: uri
clear_criteria

The criteria that ends it: {expr} or {op, value}; absent clears on the negation of fire_criteria, !(fire)

object
expr

The criterion as an expression over the sample (value, key, instance, component.name, component.type), yielding true or false; give this or op and value

string
op

The short form’s comparison: a property compares text with eq or ne; a metric compares numbers with any of them

string
Allowed values: eq ne gt ge lt le
value

The short form’s threshold: text for a property, a number for a metric

clear_event_type

The event type the rule writes when it clears, by name (rule-cleared is the generic one); absent, it writes none

string
clear_sustain

A Go duration; empty is 0s

string
description

What the rule watches for and why

string
enabled

Defaults to true

boolean
fire_criteria
required

The criteria the rule fires on: {expr}, or the short form {op, value}

object
expr

The criterion as an expression over the sample (value, key, instance, component.name, component.type), yielding true or false; give this or op and value

string
op

The short form’s comparison: a property compares text with eq or ne; a metric compares numbers with any of them

string
Allowed values: eq ne gt ge lt le
value

The short form’s threshold: text for a property, a number for a metric

fire_event_type
required

The event type the rule writes when it fires, by name (rule-fired is the generic one)

string
>= 1 characters
fire_sustain

A Go duration; empty is 0s

string
label

A human label; also the alarm message when message is empty

string
message

The alarm message; empty uses the label or the name

string
name
required

The rule’s name (lowercase kebab)

string
>= 1 characters
sample_key
required

The property or metric the rule reads

string
>= 1 characters
sample_window

A metric rule’s trend window, a Go duration up to 168h: the criteria read window, the series’ points over it, oldest first; empty is 0s, no window

string
selector

The components the rule watches (component types and components); absent is every component

object
component_types

Watch components whose type falls within one of these component types

Array<string> | null
components

Watch these components (by name or id on write; ids on read)

Array<string> | null
severity

The severity level the alarm is raised at, by name; absent or empty, the rule is informational and raises no alarm

string

Created

Media type application/json

A rule that watches signals and fires when its criteria hold, raising an alarm if it carries a severity.

object
$schema

A URL to the JSON Schema for this object.

string format: uri
clear_criteria

When the sample meets this for clear_sustain, it clears (and the alarm clears); absent, the negation of fire_criteria

object
expr
required

The criterion, an expression over the sample (value, key, instance, component.name, component.type) that yields true or false, e.g. value > 80 && instance != “aux”

string
clear_event_type

The event type the rule writes when it clears, by name; absent, it writes none

string
clear_sustain
required

How long the clear criteria must hold, a Go duration

string
criteria_error

Why the rule’s stored criteria do not compile (its key’s data type changed under them, a row the backfill left in short form, or an expression a newer diagnostic refuses); absent when they compile. While present the rule holds: it judges nothing

object
code

The registered diagnostic that gave it, when one did (documented on the expressions page)

string
column

The 1-based column of the fault, when it has one

integer format: int64
field
required

Which criteria

string
Allowed values: fire_criteria clear_criteria
line

The 1-based line of the fault, when it has one

integer format: int64
message
required
string
criteria_warnings

The warnings the stored criteria compile with (a likely mistake, such as == against a decimal), each with its code; notes only, never a fault: the rule judges all the same

Array<object> | null
object
code

The registered diagnostic that gave it, when one did (documented on the expressions page)

string
column

The 1-based column of the fault, when it has one

integer format: int64
field
required

Which criteria

string
Allowed values: fire_criteria clear_criteria
line

The 1-based line of the fault, when it has one

integer format: int64
message
required
string
description
string
enabled
required
boolean
fire_criteria
required

When the sample meets this for fire_sustain, the rule fires (and it opens an alarm when it names a severity)

object
expr
required

The criterion, an expression over the sample (value, key, instance, component.name, component.type) that yields true or false, e.g. value > 80 && instance != “aux”

string
fire_event_type
required

The event type the rule writes when it fires, by name

string
fire_sustain
required

How long the fire criteria must hold, a Go duration (0s fires at once)

string
firing
required

How many firings the rule holds right now, one per component and instance, whether or not it raises an alarm (GET /event-rules/{name}/state lists them)

integer format: int64
id
required

The rule’s uuid, the stable form of name

string
label
string
last_judged_at

When an ingested sample was last judged by the rule, to within 5s; absent when it never has been. A fleet-wide fact about the rule, naming no component

string format: date-time
message

The alarm’s message; empty uses the rule’s label or name

string
name
required
string
official
required

Shipped with the platform and read-only

boolean
open_alarms
required

How many alarms the rule raised are still open right now (its live state; GET /event-rules/{name}/state lists them)

integer format: int64
pending_streaks
required

How many of the rule’s streaks are waiting out a sustain right now

integer format: int64
sample_key
required

The property or metric the rule reads

string
sample_lane
required

Which lane the key reads, derived from the catalogs

string
Allowed values: property metric
sample_window
required

How far back the criteria’s window reads the metric’s series, a Go duration; 0s binds no window

string
selector
required

The components the rule watches; both lists empty is every component

object
component_types

Watch components whose type falls within one of these component types

Array<string> | null
components

Watch these components (by name or id on write; ids on read)

Array<string> | null
severity

The severity level the alarm is raised at, by name; absent, the rule is informational and raises no alarm

string
version
required

Bumps on every update

integer format: int64

Example

{
"$schema": "/api/v1/schemas/EventRuleBody.json",
"criteria_error": {
"field": "fire_criteria"
},
"criteria_warnings": [
{
"field": "fire_criteria"
}
],
"sample_lane": "property"
}

Error

Media type application/problem+json
object
$schema

A URL to the JSON Schema for this object.

string format: uri
detail

A human-readable explanation specific to this occurrence of the problem.

string
errors

Optional list of individual error details

Array<object> | null
object
location

Where the error occurred, e.g. ‘body.items[3].tags’ or ‘path.thing-id’

string
message

Error message text

string
value

The value at the given location

instance

A URI reference that identifies the specific occurrence of the problem.

string format: uri
status

HTTP status code

integer format: int64
title

A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

string
type

A URI reference to human-readable documentation for the error.

string format: uri
default: about:blank

Example

{
"$schema": "/api/v1/schemas/ErrorModel.json",
"detail": "Property foo is required but is missing.",
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "about:blank"
}