Create Metric Definition
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.
Authorizations
Timbal API key. Obtain your API key from the Timbal platform settings. See Authentication for more information.
Path Parameters
Body
Body for POST /orgs/{org_id}/metrics/definitions.
Every predicate field is optional and they AND together. All omitted means
"every non-root span", which paired with label_source: span_name gives a
per-step call count — a reasonable first definition.
Destination metric. trace. is prepended when missing.
Human label for the definition itself, unique within the org.
true = only errored spans, false = only clean ones, omitted = both.
none (default) or span_name to break the metric out per step.
Only spans at least this slow. Spans still running never match.
Scope to one project. Omit to apply across the org.
Defaults to trace_span, the only source today.
trace_span Exact span name — the leaf of the span path (llm, get_address),
not the full {workforce}.{step}.
Span-name prefix, for matching a family of tools (get_).
count (default), duration_ms, or usage:<key>.
Response
Definition created
none or span_name.
Always trace_span today; see [MetricDefinitionSource].
trace_span count, duration_ms, or usage:<key>.
Project scope; omitted when the filter applies to the whole org.