Preview an event rule
const url = 'https://example.com/api/v1/event-rules:preview';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"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"]}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Request Body required
Section titled “Request Body required ”object
A URL to the JSON Schema for this object.
The criteria it ends on; absent, the negation of fire_criteria
object
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
The short form’s comparison: a property compares text with eq or ne; a metric compares numbers with any of them
The short form’s threshold: text for a property, a number for a metric
Accepted and ignored, like fire_sustain
The criteria its condition starts on: {expr}, or the short form {op, value}
object
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
The short form’s comparison: a property compares text with eq or ne; a metric compares numbers with any of them
The short form’s threshold: text for a property, a number for a metric
Accepted so a rule body previews as it is, and ignored: a preview judges each sample alone
The property or metric the candidate rule reads
The components it watches; absent or empty, every component
object
Watch components whose type falls within one of these component types
Watch these components (by name or id on write; ids on read)
Responses
Section titled “ Responses ”OK
object
A URL to the JSON Schema for this object.
The edges it would have written over the window, in series and time order
object
The sample that moved it
The component, by name
The component’s uuid
The sample instance (an endpoint)
Which edge
The series the candidate would hold in force now
object
The component, by name
The component’s uuid
The sample instance (an endpoint)
When the window’s fire edge brought it into force; absent when it was in force before the window
The most window samples it reads, a whole series at a time
How many of the selected series it judged whole
How many series the candidate selects, on components the caller may read
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
object
The component, by name
The component’s uuid
The sample instance (an endpoint)
When the window’s fire edge brought it into force; absent when it was in force before the window
Always true: each sample is judged alone, so a sustain that would have held an edge back is not applied
The row cap stopped it before every series: series_judged of series_total were judged
How far back it judged, a Go duration
Example
{ "$schema": "/api/v1/schemas/PreviewEventRuleOutputBody.json", "edges": [ { "kind": "fire" } ]}default
Section titled “default ”Error
object
A URL to the JSON Schema for this object.
A human-readable explanation specific to this occurrence of the problem.
Optional list of individual error details
object
Where the error occurred, e.g. ‘body.items[3].tags’ or ‘path.thing-id’
Error message text
The value at the given location
A URI reference that identifies the specific occurrence of the problem.
HTTP status code
A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
A URI reference to human-readable documentation for the error.
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"}