> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Essential automation rules metrics

> The automation rules metrics to monitor on self-hosted LangSmith, what they measure, and how to use them.

The `queue` deployment runs [automation rules](https://docs.langchain.com/langsmith/rules.md). To enable its Prometheus endpoint, set `SAQ_METRICS_PORT` to a positive port number, such as `9090`, in the Helm value `queue.deployment.extraEnv`. The default is `0`, which disables the endpoint. The Helm chart does not create a Service for `queue`, so configure your collector to scrape `/metrics` on that port directly on the `queue` pods.

The backend API serves the three queue depth gauges on its own `/metrics`. For the backend endpoint and general export configuration, see [Export LangSmith telemetry to your observability backend](https://docs.langchain.com/langsmith/export-backend.md).

Names are as they appear on `/metrics`. If your collector adds a namespace or prefix, adjust accordingly. The [telemetry metrics list](https://docs.langchain.com/langsmith/self-host-telemetry-metrics.md) shows the same metrics with a `self_hosted_` prefix, the names your instance exports to LangChain.

For the tabbed Datadog and Grafana dashboards and their collection requirements, see [Monitor self-hosted LangSmith with Datadog or Grafana](https://docs.langchain.com/langsmith/self-host-observability-dashboards.md).

> [!NOTE]
>
> This page covers metrics that the rule worker emits. Also monitor these signals from your infrastructure monitoring:
>
> * Kubernetes: OOM kills, container restarts, and CPU and memory against limits on the `queue` pods.
> * Redis: memory use against its limit, and evicted keys. The rules queue and the bookmarks of skipped rules live in Redis.

## Scheduler

Once a minute, the scheduler enqueues one job per rule window that is due. The three `langsmith_saq_queue_*` gauges count those jobs and are served by the backend API, not the `queue` deployment. Every backend pod reports the same value for the whole queue.

| Metric | Description |
| - | - |
| [`langsmith_run_rules_bookmark_write_failures_total`](#langsmith_run_rules_bookmark_write_failures_total) | Failed Redis writes of skipped rule bookmarks. |
| [`langsmith_saq_queue_queued`](#langsmith_saq_queue_queued) | Rule jobs waiting for a worker. |
| [`langsmith_saq_queue_active`](#langsmith_saq_queue_active) | Rule jobs a worker is running now. |
| [`langsmith_saq_queue_scheduled`](#langsmith_saq_queue_scheduled) | Rule jobs scheduled for a later time. |

### `langsmith_run_rules_bookmark_write_failures_total`

*Counter*

Failed Redis pipelines when writing the bookmark of a skipped rule. After a failure, the scheduler writes that batch and the rest of the tick's bookmarks to PostgreSQL instead, so rule progress is kept. The counter adds at most one per scheduler tick. A non-zero rate points at a Redis problem and adds PostgreSQL writes.

Query: Use the rate, summed across pods.

### `langsmith_saq_queue_queued`

*Gauge*

Rule jobs waiting for a worker. Growth that continues while traffic is stable is the first sign that the rule workers do not keep up. Confirm with `langsmith_run_rules_window_lag_seconds`, then add `queue` replicas.

Query: Filter on `queue_name="rules"`. Use max across pods, not sum.

### `langsmith_saq_queue_active`

*Gauge*

Rule jobs a worker is running now.

Query: Filter on `queue_name="rules"`. Use max across pods, not sum.

### `langsmith_saq_queue_scheduled`

*Gauge*

Rule jobs scheduled for a later time.

Query: Filter on `queue_name="rules"`. Use max across pods, not sum.

## Worker

An attempt is one job that applies a rule to part or all of a window. A window can take multiple jobs, and each retry counts as a separate attempt. The metrics below follow an attempt from window lag and unit pickup latency to action results and the overall result. The `applier_*` metrics describe the actions that run during each attempt. See [Labels](#labels) for which labels each metric declares.

| Metric | Description |
| - | - |
| [`langsmith_run_rules_window_lag_seconds`](#langsmith_run_rules_window_lag_seconds) | Time from the end of the window to the start of a live attempt. |
| [`langsmith_run_rules_run_pickup_latency_seconds`](#langsmith_run_rules_run_pickup_latency_seconds) | Time from a run, thread, or trajectory becoming eligible to a rule picking it up. |
| [`langsmith_run_rules_applier_runs_processed_total`](#langsmith_run_rules_applier_runs_processed_total) | Per action, how many units it was handed. |
| [`langsmith_run_rules_applier_run_outcomes_total`](#langsmith_run_rules_applier_run_outcomes_total) | Per action, one per unit that came back with a result, split by success or error. |
| [`langsmith_run_rules_applier_results_total`](#langsmith_run_rules_applier_results_total) | One count per action that runs during an attempt, labeled with that action's result. |
| [`langsmith_run_rules_applier_duration_seconds`](#langsmith_run_rules_applier_duration_seconds) | Time one action took during one attempt. |
| [`langsmith_run_rules_apply_run_rule_results_total`](#langsmith_run_rules_apply_run_rule_results_total) | One count per attempt, labeled with its result. |
| [`langsmith_run_rules_apply_run_rule_duration_seconds`](#langsmith_run_rules_apply_run_rule_duration_seconds) | Time one attempt took, from job start to its result. |

### `langsmith_run_rules_window_lag_seconds`

*Histogram*

Time from the end of the window to the start of a live attempt. A rule catching up after a pause trails by hours without being stuck. A lag that rises while traffic is stable means rules are falling behind. Backfills are excluded.

Query: The highest bucket is 86400 s. Use max across pods.

### `langsmith_run_rules_run_pickup_latency_seconds`

*Histogram*

Time from a run, thread, or trajectory becoming eligible to a rule picking it up. For a thread or trajectory, the project's idle window is excluded. Backfills are excluded.

Query: The highest bucket is 86400 s. Split by `unit_kind` and by `source` to find the slow action type.

### `langsmith_run_rules_applier_runs_processed_total`

*Counter*

Per action, how many units it was handed. A unit is a run, a thread, or a trajectory, by the rule's `unit_kind`. A rule with two actions over 50 units adds 100.

Query: Use the rate, summed across pods. Split by `source` to see which action type does the work.

### `langsmith_run_rules_applier_run_outcomes_total`

*Counter*

Per action, one per unit that came back with a result, split by success or error. An action can receive a unit without returning an outcome for it. `result="error"` means the action reported an error for that unit. The metric does not identify the cause. The `outcome` label carries the same value as `result`.

Query: Use the rate, summed across pods. Split by `source` and `result`.

### `langsmith_run_rules_applier_results_total`

*Counter*

One count per action that runs during an attempt, labeled with its `result`: `success`, `error`, or `skipped`. If an attempt runs both an evaluator and a webhook, it adds two counts, one for each action. A retry adds a count for each action it runs again. `result="error"` means the action failed during that attempt. The share of `result="success"` per `source` is the success rate of that action type.

Query: Use the rate, summed across pods. Split by `source` and `result`.

### `langsmith_run_rules_applier_duration_seconds`

*Histogram*

Time one action took during one attempt. Rising for one `source` points at that action's model or endpoint. Rising for all points at capacity.

Query: The highest bucket is 600 s. Split by `source`.

### `langsmith_run_rules_apply_run_rule_results_total`

*Counter*

One count per attempt, labeled with its result: `success`, `skipped`, or `error`. Each retry of a window adds another count. A rate of zero while runs arrive means the worker is not recording attempts. On `result="error"`, `fault="user"` means you need to act, for example to fix the rule's configuration or raise a workspace usage limit, and `fault="system"` means a LangSmith problem. LangSmith can retry a window after a `transient_error`, but not after a `permanent_error`.

Query: Use the rate, summed across pods. Split by `result`, then by `error_type` and `fault` for errors. Filter on `pointer_type="live"` to leave out backfills.

### `langsmith_run_rules_apply_run_rule_duration_seconds`

*Histogram*

Time one attempt took, from job start to its result. Rising duration can indicate a capacity issue or a slow dependency. To compare action types, use `langsmith_run_rules_applier_duration_seconds` instead.

Query: The highest bucket is 600 s, so percentiles do not show longer attempts. Split by `result`.

## Specific applier types

Only custom code evaluators record metrics of their own. The other action types are covered by the `applier_*` metrics above.

| Metric | Description |
| - | - |
| [`langsmith_run_rules_code_evaluator_missing_at_dispatch_total`](#langsmith_run_rules_code_evaluator_missing_at_dispatch_total) | Code evaluator rules that reached dispatch without their code. |
| [`langsmith_run_rules_code_evaluator_feedback_truncated_total`](#langsmith_run_rules_code_evaluator_feedback_truncated_total) | Code evaluator applications whose feedback fetch hit the row limit. |
| [`langsmith_run_rules_code_evaluator_result_failures_total`](#langsmith_run_rules_code_evaluator_result_failures_total) | Code evaluator results that did not succeed. |

### `langsmith_run_rules_code_evaluator_missing_at_dispatch_total`

*Counter*

Code evaluator rules that reached dispatch without their code. `result="error"` is a rule whose evaluator has no code. `result="success"` is code that loaded late.

Query: Use the rate, summed across pods.

### `langsmith_run_rules_code_evaluator_feedback_truncated_total`

*Counter*

Code evaluator applications whose feedback fetch hit the row limit, so some feedback was left out of the evaluator payload.

Query: Use the rate, summed across pods.

### `langsmith_run_rules_code_evaluator_result_failures_total`

*Counter*

Code evaluator results that did not succeed, for example a sandbox timeout, and were written as error feedback instead of a score.

Query: Use the rate, summed across pods. Split by `status`.

## Labels

All metrics in the **Worker** table and `langsmith_run_rules_code_evaluator_missing_at_dispatch_total` declare `source`, `unit_kind`, `pointer_type`, and `rule_owner`. Additional labels depend on the metric. The names below omit the `langsmith_run_rules_` prefix:

* `apply_run_rule_*`, `applier_results_total`, `applier_duration_seconds`, and `code_evaluator_missing_at_dispatch_total` also declare `result`, `error_type`, and `fault`.
* `applier_run_outcomes_total` also declares `result` and `outcome`.
* `window_lag_seconds`, `run_pickup_latency_seconds`, and `applier_runs_processed_total` declare no additional labels.

`bookmark_write_failures_total` and `code_evaluator_feedback_truncated_total` have no labels. `code_evaluator_result_failures_total` has only `status`. The queue depth gauges use `queue_name` to identify the queue.

| Label | Values |
| - | - |
| `source` | `orchestration` on `window_lag_seconds`. On `apply_run_rule_*`, `orchestration` for successful and skipped attempts and for errors outside an action. An error raised by an action carries that action's applier class, and a usage limit error carries `usage_limit`. On `run_pickup_latency_seconds` and `applier_*`, the action's applier class: `OnlineEvaluatorRuleApplier`, `TrajectoryEvaluatorRuleApplier`, `CustomCodeRuleApplier`, `SandboxCodeRuleApplier`, `WebhookRuleApplier`, `AddToDatasetRuleApplier`, `AddToAnnotationQueueRuleApplier`, `AlertRuleApplier`, or `ExtendOnlyRuleApplier`. On `code_evaluator_missing_at_dispatch_total`, `CustomCodeRuleApplier` or `SandboxCodeRuleApplier`. |
| `result` | `success`, `skipped`, or `error`. On `apply_run_rule_*`, this is the attempt result. On `applier_results_total` and `applier_duration_seconds`, it is the action result. |
| `outcome` | On `applier_run_outcomes_total`, the per-unit result. It matches `result` on that metric. |
| `status` | On `code_evaluator_result_failures_total`, the code evaluator result status. |
| `error_type` | `permanent_error`, `transient_error`, or `usage_limit_error`. Empty on success and skipped results. On `applier_*`, also empty when an action reports `result="error"` without raising. |
| `fault` | `user` when you need to act, for example on the rule's configuration or a workspace usage limit. `system` for a LangSmith problem. Empty whenever `error_type` is empty. |
| `unit_kind` | `run`, `thread`, or `trajectory`. |
| `pointer_type` | `live` or `backfill`. Empty outside a rule window, for example a playground evaluation. A backfill is a one-time catch-up over past traces. Read live health with it filtered out. |
| `rule_owner` | `unspecified` unless LangSmith created the rule on your behalf. |

Histograms are exported with Prometheus buckets. If your collector converts them to distributions, as the Datadog OpenMetrics check does, query percentiles from the distribution rather than from `_bucket` series.

## Terms

| Term | Meaning |
| - | - |
| Attempt | One job that applies a rule to part or all of a window of runs, threads, or trajectories. Each retry counts as a separate attempt. |
| Action | An operation a rule applies to the window's matched units, such as an evaluator or a webhook. On action metrics, `source` carries the applier class. |
| Unit | One run, thread, or trajectory that a rule processes. The `unit_kind` label names which. |
| Backfill | A one-time catch-up over past traces. It starts only when you create a rule with a backfill start date. |

***

[Connect these docs](https://docs.langchain.com/use-these-docs.md) to your agent of choice via MCP for real-time answers.

[Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/self-host-run-rules-metrics.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
