# Evaluation monitors

**Last updated:** 2026-11-27T14:16:11-03:00 (UTC-3)

A monitor watches one number about a team's evaluations and tells a channel when it crosses a threshold and when it recovers: an evaluator's pass rate falling below 80%, more than ten failed results in an hour, the judge spend of a day, a burst of spans matching a query, or an evaluator that became degraded. Monitors are a tenant feature behind `features.evaluation_monitors`, off by default; they require `evaluation_results`. Delivery uses the [alert channels](/docs/features/alerting/) (`alert_channels`), and with [alert rules](/docs/features/alert-rules/) on, a monitor in warning or alert also holds an alert on the **Alerts** screen.

## Turn it on

```yaml
features:
  evaluation_results: true
  evaluation_monitors: true
  alert_channels: true      # to deliver
  alert_rules: true         # optional: alerts on the Alerts screen
evaluation:
  monitors:
    tick: 30s
    max_per_team: 50
    backtest_days: 7
    console_url: https://gateway.example.com
```

| Setting | Default | What it does |
|---|---|---|
| `evaluation.monitors.tick` | `30s` (5s to 5m) | How often each replica looks for monitors that are due. |
| `evaluation.monitors.max_per_team` | 50 (1 to 200) | Monitors one team keeps, YAML and stored together. |
| `evaluation.monitors.backtest_days` | 7 (1 to 7) | How far back a backtest replays. |
| `evaluation.monitors.console_url` | none | The public address of the console (`https`, no query or fragment). Alert links are built under it. Without it a link is the console path alone (`/ui/#/traces?...`). |
| `evaluation.monitors.items[]` | empty | Monitors declared in YAML, read-only in the console (see [YAML](#monitors-in-yaml)). |

The block, the YAML monitors included, is read at startup: restart the gateway to apply a change. Monitors created in the console or through the API apply at once. A span query monitor also needs `trace_query` and `span_store`; an [average-latency monitor](#watch-the-average-latency-of-traces) needs `trace_latency_monitors` and `span_store` (and `trace_query` when it has a query).

## What a monitor watches

| Type | The number | Example |
|---|---|---|
| `evaluation_pass_rate` | `pass / (pass + fail)` of an evaluation's results with status `ok`, a fraction from 0 to 1 | pass rate of `helpfulness` below 0.8 with at least 20 results in 1 h |
| `evaluation_count` | How many results have an assessment (`fail` by default, or `pass`, `none`, `any`), optionally one label | more than 10 failed results of `tone` in 1 h; more than 0 `negative` results of `sentiment` in 5 m |
| `evaluation_judge_cost` | The judge cost the ledger knows, in US dollars | judge spend of `helpfulness` above 5 in 24 h |
| `span_query` | How many spans, or with `counts: traces` how many traces, match a query of the [query language](/docs/features/query-language/) | `fell_back:true model:chat-default` above 50 in 15 m; `guardrail.blocked:true` above 5 in 10 m; `status:error` above 1 in 5 m; traces with `trace.tokens>500` above 20 in 1 h |
| `trace_latency` | The average duration of the traces that match a query (every trace of the team without one), in milliseconds; needs `trace_latency_monitors` | traces of `model:chat-default` above 2000 ms on average in 15 m, with at least 5 traces |
| `evaluator_health` | The [evaluator's health](/docs/features/evaluation-tracing/#evaluator-health-and-cost) | `helpfulness` is degraded or blocked |

Experiment results are left out of the first three. A monitor reads only its own team's results and spans, and of those only what was recorded in the team's current organization.

An evaluation monitor may narrow the judged traffic with `query`, in the query language, by `model`, `key`, `session` and `end_user` (for example `model:chat-default`). A span query monitor counts spans by their own fields, evaluation results included (`evaluation.sentiment.value:negative`), without `child.` or `parent.` terms and without text search.

### Count traces by their aggregates

A question about a whole trace (an agent run that took more than 500 tokens, more than ten model calls, any span in error) is not a question about one span. Set `counts: traces` and the monitor counts the traces whose summary matches the query, at the step a trace started in, with the fields of the traces scope, the trace aggregates among them:

| Field | What it is |
|---|---|
| `trace.tokens` | Input plus output tokens of the whole trace |
| `trace.spans`, `trace.llm_calls`, `trace.tool_calls` | Spans, model calls and tool calls in the trace |
| `trace.errors` | Spans in error in the trace |
| `cost`, `duration`, `model`, `status`, `origin`, ... | The trace's cost, duration from its first to its last span, the models it used, its status (an error when any span is) |

```yaml
      - id: heavy-runs
        name: Heavy agent runs
        team_id: payments
        type: span_query
        counts: traces
        query: "trace.tokens>500 trace.llm_calls>=3"
        threshold: 20
        window: 1h
        every: 5m
```

Leave `counts` out and the query decides: a query that names a trace aggregate (`trace.tokens`, `trace.spans`, `trace.llm_calls`, `trace.tool_calls`, `trace.errors`) counts traces, any other query counts spans. `counts: spans` with a trace aggregate is refused with the field named. A trace counts for the team's own spans recorded in its current organization, as on the Traces screen, from the same span engine; the alert's link opens the Traces screen on the traces of the window. The monitor view reports what it counts in `applied.counts`.

### Watch the average latency of traces

`span_query` counts the traces that match; `trace_latency` watches how long they take. Turn on `trace_latency_monitors` (a tenant resource: with plan entitlements, the team's plan must include it) and declare:

```yaml
      - id: slow-chat
        name: Slow chat traces
        team_id: payments
        type: trace_latency
        query: "model:chat-default"   # optional: every trace of the team without it
        comparison: gt
        threshold: 2000               # milliseconds
        warning_threshold: 1500
        min_count: 5
        window: 15m
        every: 5m
```

At each step the monitor reads the traces of the window that match the query (the fields of the traces scope, trace aggregates included), and divides the sum of their durations (from the first span's start to the last span's end) by their count. Each trace counts at the step it started in, for the team's own spans recorded in its current organization, from the span engine the Traces screen reads. A window with no trace has no value, and `min_count` (default 1) is the fewest traces a window needs; below it the window is *no data* and `no_data` decides. The backtest replays the same per-step sums. The alert names the average in milliseconds and links to the matching traces of the window.

## How a monitor is judged

A monitor has a **window** (5 m to 24 h) and a step, **every** (1 m to 1 h, whole minutes). The window is a whole number of steps. Steps start at whole multiples of `every` since the Unix epoch, so a monitor with `every: 5m` is judged at :00, :05, :10 and reads exactly the window that ended there.

At each step the monitor's number is compared with its thresholds:

| State | When |
|---|---|
| `alert` | the number crosses `threshold` (`comparison`: `lt`, `lte`, `gt`, `gte`) |
| `warn` | it crosses `warning_threshold`, which must be crossed before the alert threshold |
| `ok` | otherwise |

**Not enough data.** A pass rate over three results says little. `min_count` is the fewest pass or fail results a window needs (default 1). A window below it is *no data*, and `no_data` says what that means: `keep` the state the monitor was in (the default), read it as `ok`, or `alert`. A count, a spend and a span count are never "no data": zero is a number.

**What is sent.** Entering `warn` or `alert` sends `evaluation_monitor_alert`; returning to `ok` sends `evaluation_monitor_recovered`. With `renotify` (5 m to 7 days) the alert is sent again while the monitor stays in warning or alert. A muted monitor keeps being judged and records its transitions, and sends nothing, with one exception: the recovery of an alert it had already announced is sent, so a channel that holds it open (a PagerDuty incident) can close it.

**Closed outside a judgement.** A monitor in warning or alert returns to OK, sends the recovery to the channels that were told of the alert and resolves its alert on the Alerts screen when it is paused, edited or deleted, or when its team's plan loses the right. A YAML monitor removed from the configuration has its alert resolved; its channels are no longer known, so no recovery is sent for it.

A monitor is judged within one or two ticks of each step by one replica at a time (a lease in the database). A step missed while every replica was down is not replayed. A read that fails (the analytics store is unavailable, the query matches more traces than one query holds) keeps the state, shows the reason on the monitor and is tried again within a minute.

An `evaluator_health` monitor has no window or threshold: it reads the evaluator's health as the Evaluators tab shows it, over the last 24 hours, and alerts on `degraded` (which also covers `blocked`) or on `blocked` alone.

## Backtest

**Backtest** in the form, or `POST /api/v1/admin/monitors/backtest`, replays the monitor over the last `backtest_days` days in its own steps and says how many times it would have entered alert and warning and recovered, starting from OK. It applies the scheduler's rule to the same per-step counts, so it counts what the scheduler would have recorded. It stores and sends nothing.

The chart shows the number at each step with the thresholds, and under it the state at each step. For an `evaluator_health` monitor the backtest replays the degraded rule only: blocked periods are not kept in history.

## Channels and what they receive

A monitor names up to 8 alert channels. A channel can be named by a team's monitors when it:

1. subscribes to `evaluation_monitor_alert`, `evaluation_monitor_recovered` or both, and
2. is open to the team: it lists the team in `rule_teams`, or the team's organization in `rule_organizations` ([alert channels](/docs/features/alerting/)).

Subscribing only makes a channel selectable. A monitor's events go to the channels that monitor names, never to every subscriber, so one team's alert never reaches another team's channel.

A webhook receives:

```json
{
  "event": "evaluation_monitor_alert",
  "delivery_id": "oncall:aevt_5f0c...",
  "sent_at": "2026-11-25T12:05:03Z",
  "monitor": {
    "transition_id": "mtr_91ab...",
    "monitor_id": "mon_3f2a...",
    "name": "Helpfulness pass rate",
    "team_id": "payments",
    "type": "evaluation_pass_rate",
    "kind": "alert",
    "state": "alert",
    "previous_state": "ok",
    "severity": "critical",
    "evaluation": "helpfulness",
    "comparison": "lt",
    "threshold": 0.8,
    "value": 0.615,
    "count": 40,
    "min_count": 20,
    "no_data": false,
    "window_seconds": 3600,
    "every_seconds": 300,
    "window_from": "2026-11-25T11:05:00Z",
    "window_to": "2026-11-25T12:05:00Z",
    "at": "2026-11-25T12:05:02Z",
    "link": "https://gateway.example.com/ui/#/traces?lens=evaluations&q=evaluation.helpfulness.assessment%3Afail&from=2026-11-25T11%3A05%3A00Z&to=2026-11-25T12%3A05%3A00Z",
    "traces_query": "evaluation.helpfulness.assessment:fail"
  },
  "message": "m7gtw: monitor Helpfulness pass rate (team payments) is in alert [critical]: pass rate of helpfulness is 61.5% over 1h (40 counted); the rule is < 80.0%. https://..."
}
```

- The schema is the same for both events and every monitor type; numbers are numbers. `kind` is `alert`, `warn`, `recovered`, `renotify` or `test`. `value` is `null` when the window said nothing.
- **`link`** opens the Traces screen with `traces_query` and the window applied: the failing results of the evaluator, or the spans the query matched. From there the trace, its results, its Logs tab and "add to dataset" are one click each.
- Every delivery is signed: `X-Gateway-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">` with the channel's signing secret, plus `X-Gateway-Event` and `Idempotency-Key`. Retries, the delivery history and secret rotation are those of every [alert channel](/docs/features/alerting/).
- Slack, Microsoft Teams and email receive `message`. PagerDuty gets one incident per monitor: warning or alert triggers it, a renotification updates it and the recovery resolves it.

**Send test notification** on a monitor (or `POST /monitors/{id}/test`) queues the alert event with `kind: test` through the same path, so the channel's deliveries show whether it arrived. The form shows the body a channel would receive.

## The Monitors tab

**Evals → Monitors** lists the monitors of your teams with their state (alert, warning, OK, paused), what each does in one sentence, its last value and a link to the matching traces. Per monitor: its history of transitions, the monitor as YAML, mute, test notification, edit and delete.

The form is a sentence you fill in: what to watch, for which team and evaluation, the comparison and thresholds, the window and step, the minimum count, what to do without data, the severity, renotification and the channels. For a span query monitor, choosing an evaluation and an assessment writes the query, and a query of that form fills the choice back.

Other places:

- **Evals → Evaluators** has a Monitors column with the number of monitors of each evaluator and their worst state, and starts a **Pass-rate monitor**, a **Failure count monitor** or a **Judge spend monitor** with the evaluator and its team filled in. With [evaluators](/docs/features/evaluators/#the-console) the column shows the count and state, and the three monitors start from the evaluator page's **Monitors** tab.
- **Traces** and **Usage → Quality** show how many monitors are in alert, in warning and OK, with a link to the ones that need attention.
- **Alerts**, with `alert_rules`: a monitor in warning or alert holds an alert there (source `evaluation_monitor`), resolved when it recovers, is edited or is deleted.

A team with no channel is told so in the form, with a link to **Settings → Alert channels**.

## Monitors in YAML

```yaml
evaluation:
  monitors:
    items:
      - id: helpfulness-pass-rate
        name: Helpfulness pass rate
        team_id: payments
        type: evaluation_pass_rate
        evaluation: helpfulness
        comparison: lt
        threshold: 0.8
        warning_threshold: 0.9
        window: 1h
        every: 5m
        min_count: 20
        renotify: 6h
        severity: critical
        channels: [oncall]
      - id: sentiment-negative
        name: Negative sentiment
        team_id: payments
        type: span_query
        query: "evaluation.sentiment.value:negative"
        threshold: 0
        window: 5m
        every: 1m
      - id: helpfulness-health
        name: Helpfulness evaluator health
        team_id: payments
        type: evaluator_health
        evaluator_id: ev_3f2a9c
```

| Field | Meaning |
|---|---|
| `id`, `name`, `description`, `team_id`, `type` | Identity and owner. `id` is a lowercase letter and up to 63 lowercase letters, digits, `_` or `-`. |
| `evaluation`, `evaluator_id` | The results read: by name, or by evaluator (the monitor then follows a rename). `evaluator_health` needs `evaluator_id`. |
| `assessment`, `value` | `evaluation_count`: the assessment counted and, optionally, one label. `evaluator_health`: `value` is `degraded` or `blocked`. |
| `query` | `span_query`: the spans (or traces) counted. `trace_latency`: the traces whose average duration is watched (traces scope), optional. Evaluation types: an optional narrowing by `model`, `key`, `session`, `end_user`. At most 1024 bytes. |
| `counts` | `span_query` only: `spans` or `traces` ([above](#count-traces-by-their-aggregates)); empty lets the query decide. |
| `comparison`, `threshold`, `warning_threshold` | `lt`, `lte`, `gt`, `gte` (default `lt` for a pass rate, `gt` otherwise) and the two thresholds; a `trace_latency` threshold is in milliseconds. |
| `window` | The trailing range judged at each step, `5m` to `24h`; default `1h`. A whole number of `every` steps. |
| `every` | The step between two judgements, `1m` to `1h` in whole minutes; default `5m`. |
| `min_count`, `no_data` | Pass rate (results) and `trace_latency` (traces) only, default 1; `keep`, `ok` or `alert`. |
| `renotify`, `severity`, `channels`, `disabled` | Repeat interval; `info`, `warning` or `critical`; channel IDs declared in YAML too; `disabled: true` pauses. |

A YAML monitor is read-only in the console and the API (409 `yaml_managed`), and can still be muted. The **As YAML** view of a stored monitor is an entry you can paste here: it keeps the monitor's ID, so the declared monitor takes the stored one's place with the same behavior.

## API

With the console session.

| Call | What it does |
|---|---|
| `GET /api/v1/admin/monitors` | The monitors the session may see, with state, counts by state and the vocabulary. |
| `POST /api/v1/admin/monitors` | Create. The gateway assigns the ID (`mon_...`). |
| `GET /api/v1/admin/monitors/{id}` | One monitor with its last 100 transitions, its YAML, its channels and an example payload. |
| `PUT /api/v1/admin/monitors/{id}` | Replace at `version`. The monitor is judged afresh from OK. |
| `DELETE /api/v1/admin/monitors/{id}` | Delete at `?version=`. History stays for 90 days. |
| `POST /api/v1/admin/monitors/{id}/mute` | `{"duration":"8h"}` mutes; an empty duration ends the mute. |
| `POST /api/v1/admin/monitors/{id}/test` | Queue a test notification. |
| `POST /api/v1/admin/monitors/backtest` | Replay a monitor that may not be stored yet. |
| `GET /api/v1/admin/monitors/channels` | The channels a team's monitors may name. |
| `GET /api/v1/admin/evaluation/settings` | The `evaluation` block in effect (with the evaluator settings of [evaluators](/docs/features/evaluators/#settings)), each value marked default or configured, and the YAML monitors the session may see. Needs `config:read`. |

Query parameters of the list, `GET /api/v1/admin/monitors`:

- `team` keeps one team's monitors.
- `evaluator_id` keeps the monitors of one evaluator, and `evaluation` those that name one evaluation.
- `type` keeps one monitor type, for example `type=span_query`.
- `state` keeps the monitors in one state: `ok`, `warn`, `alert` or `paused`.

`GET /api/v1/admin/monitors/channels` takes `team`, the team whose channels to list, as in `?team=payments`.

## Who sees what

| Permission | Who |
|---|---|
| `monitors:read` | admin and viewer; `team_admin`, `team_viewer` and `user` within their own teams |
| `monitors:manage` | admin everywhere; `team_admin` on the teams it administers. A custom role never holds it. |
| `monitors:global` | widens the two above to every team: admin, and viewer read-only |

- Without `monitors:global`, a session sees the monitors of its own teams and nothing of another team or organization. A monitor outside its scope answers 404, the same as one that does not exist.
- With plan entitlements, only teams whose plan includes `evaluation_monitors` (and `evaluation_results`) have monitors. A team that loses the right keeps its monitors unjudged.
- A monitor's evaluator must belong to the monitor's team, and its channels must be open to that team. The answer for a channel of another tenant is the same as for a channel that does not exist.
- A team that moves to another organization keeps its monitors. They start again from OK there, and their earlier history is not shown to the new organization.
- Creating, editing, deleting and muting are audited (`monitor.create`, `monitor.update`, `monitor.delete`, `monitor.mute`, `monitor.unmute`).

## Metrics and logs

| Series | Labels |
|---|---|
| `gateway_evaluation_monitor_evaluations_total` | `type`, `outcome` (`ok`, `warn`, `alert`, `no_data`, `error`, `lost_lease`) |
| `gateway_evaluation_monitor_transitions_total` | `type`, `kind` (`alert`, `warn`, `recovered`, `renotify`) |

Monitor, team and organization IDs are never labels. Each transition is also a log line `evaluation_monitor` with the monitor, team, organization, kind, state and value, which the OTLP logs carry.
