Skip to content

Preview an event rule

POST
/event-rules:preview
curl --request POST \
--url https://example.com/api/v1/event-rules:preview \
--header 'Content-Type: application/json' \
--data '{ "clear_criteria": { "expr": "example", "op": "eq", "value": "example" }, "clear_sustain": "example", "fire_criteria": { "expr": "example", "op": "eq", "value": "example" }, "fire_sustain": "example", "sample_key": "example", "selector": { "component_types": [ "example" ], "components": [ "example" ] } }'

Judges a candidate rule (sample key, selector, criteria) without writing anything, as the ingest would have with no sustains (the answer says they are ignored): over each series it selects on components the caller may read, from the state its newest deciding sample in the 7 days before the window set (state_unknown when there is none), through every sample in the last 24 hours that the ingest would have judged (a late sample older than one before it decides nothing). Answers the edges it would have written and the series it would hold in force now. Its reads are index probes per series, capped at row_cap window samples taken a whole series at a time: series_judged of series_total, and truncated when the cap stopped it. A selector naming a component the caller cannot read is the same 422 as one that does not exist. Criteria take {expr} or {op, value}; one that does not compile is a 422 naming the criteria, line and column. Gated by rule:read.

Media type application/json
object
$schema

A URL to the JSON Schema for this object.

string format: uri
clear_criteria

The criteria it ends on; absent, the negation of fire_criteria

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_sustain

Accepted and ignored, like fire_sustain

string
fire_criteria
required

The criteria its condition starts 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_sustain

Accepted so a rule body previews as it is, and ignored: a preview judges each sample alone

string
sample_key
required

The property or metric the candidate rule reads

string
>= 1 characters
selector

The components it watches; absent or empty, 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

OK

Media type application/json
object
$schema

A URL to the JSON Schema for this object.

string format: uri
edges
required

The edges it would have written over the window, in series and time order

Array<object> | null
object
at
required

The sample that moved it

string format: date-time
component
required

The component, by name

string
component_id
required

The component’s uuid

string
instance

The sample instance (an endpoint)

string
kind
required

Which edge

string
Allowed values: fire clear
in_force_now
required

The series the candidate would hold in force now

Array<object> | null
object
component
required

The component, by name

string
component_id
required

The component’s uuid

string
instance

The sample instance (an endpoint)

string
since

When the window’s fire edge brought it into force; absent when it was in force before the window

string format: date-time
row_cap
required

The most window samples it reads, a whole series at a time

integer format: int64
series_judged
required

How many of the selected series it judged whole

integer format: int64
series_total
required

How many series the candidate selects, on components the caller may read

integer format: int64
state_unknown
required

The series with no sample that fires or clears in the 7 days before the window: their first such sample in the window set their state without an edge, since whether it moved anything is not known

Array<object> | null
object
component
required

The component, by name

string
component_id
required

The component’s uuid

string
instance

The sample instance (an endpoint)

string
since

When the window’s fire edge brought it into force; absent when it was in force before the window

string format: date-time
sustains_ignored
required

Always true: each sample is judged alone, so a sustain that would have held an edge back is not applied

boolean
truncated
required

The row cap stopped it before every series: series_judged of series_total were judged

boolean
window
required

How far back it judged, a Go duration

string
window_since
required
string format: date-time
window_until
required
string format: date-time
Example
{
"$schema": "/api/v1/schemas/PreviewEventRuleOutputBody.json",
"edges": [
{
"kind": "fire"
}
]
}

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"
}