Define a custom metric
Define a metric of your own, emitted as runs land. Once it exists it behaves like any platform metric: readable through GET /orgs/{org_id}/metrics, listed in the catalog with origin: custom, and alarmable with no extra setup.
The definition is a span predicate over each completed run's trace. Span paths are {workforce}.{step} and matching is on the leaf: use llm or get_address, not the full path. Predicate fields AND together and all are optional — omitting every one matches every non-root span.
metric_name is forced under the reserved trace. prefix so a definition cannot shadow a platform series. Set label_source to span_name to break the metric out per step, then point an alarm at a single step with dims.label.
Definitions are not retroactive: matching happens as runs arrive, so a new definition only sees traces written after it. Dry-run it against stored traces first with POST /orgs/{org_id}/metrics/definitions/preview. Note also that only sum/count/avg/min/max are available on the result — percentiles are not derivable from metric bins.
Set project_id to scope the definition to one project, which also makes it editable by holders of projects.alarms.manage there. Leaving it out defines an org-wide metric that runs against every project's traces, and needs alarms.manage.
Path parameters
Request body
Response
Definition created