v51

latestOpenAPI 3.1.0raw.githubusercontent.com2026-08-01206322659.2 KB
alarms

Dry-run a custom metric definition

Run a candidate predicate against recent stored traces without saving it, and see what it would have recorded.

Definitions are not retroactive, so a saved predicate that matches nothing looks identical to one that matches nothing yet. This answers that before you commit: which spans matched, what values they'd contribute, and how many distinct labels the metric would carry.

Samples the newest runs (20 by default, 50 max) — enough to tell a working predicate from a broken one, not a measurement of the true rate. Pass workforce_id to make the sample representative of the agent you're actually matching. This is the only endpoint that reads stored traces, which is why it is capped; do not poll it.

Because it returns trace content, project_id doubles as the permission target: omit it and the sample spans the whole org, which needs alarms.manage; set it and the sample is capped to that project, which needs projects.alarms.manage there. A caller scoped to one project must therefore pass it.

post/orgs/{org_id}/metrics/definitions/preview

Path parameters

org_idstring required

Request body

has_errorboolean nullable
label_sourcestring
limitinteger nullable

Runs to inspect, newest first. Default 20, max 50.

min_duration_msinteger nullable
project_idstring nullable

Sample runs from one project only.

span_namestring nullable
span_name_prefixstring nullable
status_codestring nullable
value_sourcestring
workforce_idstring nullable

Sample runs from one agent/workflow (OrgsApps.id). Strongly recommended: it makes the sample representative of what you're filtering, instead of whatever the org ran most recently.

Response

What the definition would record

observationsinteger required

Total matching spans across the sample.

runs_matchedinteger required

Of those, how many produced at least one observation.

runs_sampledinteger required

Runs with a trace that were actually inspected.