



























@@ -0,0 +1,89 @@
1+---
2+summary: "Expose OpenClaw diagnostics as Prometheus text metrics through the diagnostics-prometheus plugin"
3+title: "Prometheus metrics"
4+read_when:
5+ - You want Prometheus, Grafana, VictoriaMetrics, or another scraper to collect OpenClaw Gateway metrics
6+ - You need the Prometheus metric names and label policy for dashboards or alerts
7+ - You want metrics without running an OpenTelemetry collector
8+---
9+10+OpenClaw can expose diagnostics metrics through the bundled
11+`diagnostics-prometheus` plugin. It listens to trusted internal diagnostics and
12+renders a Prometheus text endpoint at:
13+14+```text
15+/api/diagnostics/prometheus
16+```
17+18+The route uses Gateway authentication. Do not expose it as a public
19+unauthenticated `/metrics` endpoint.
20+21+## Quick start
22+23+```json5
24+{
25+ plugins: {
26+ allow: ["diagnostics-prometheus"],
27+ entries: {
28+"diagnostics-prometheus": { enabled: true },
29+ },
30+ },
31+ diagnostics: {
32+ enabled: true,
33+ },
34+}
35+```
36+37+You can also enable the plugin from the CLI:
38+39+```bash
40+openclaw plugins enable diagnostics-prometheus
41+```
42+43+Then scrape the protected Gateway route with the same Gateway authentication you
44+use for operator APIs.
45+46+## Metrics exported
47+48+| Metric | Type | Labels |
49+| --------------------------------------------- | --------- | ----------------------------------------------------------------------------------------- |
50+| `openclaw_run_completed_total` | counter | `channel`, `model`, `outcome`, `provider`, `trigger` |
51+| `openclaw_run_duration_seconds` | histogram | `channel`, `model`, `outcome`, `provider`, `trigger` |
52+| `openclaw_model_call_total` | counter | `api`, `error_category`, `model`, `outcome`, `provider`, `transport` |
53+| `openclaw_model_call_duration_seconds` | histogram | `api`, `error_category`, `model`, `outcome`, `provider`, `transport` |
54+| `openclaw_model_tokens_total` | counter | `agent`, `channel`, `model`, `provider`, `token_type` |
55+| `openclaw_gen_ai_client_token_usage` | histogram | `model`, `provider`, `token_type` |
56+| `openclaw_model_cost_usd_total` | counter | `agent`, `channel`, `model`, `provider` |
57+| `openclaw_tool_execution_total` | counter | `error_category`, `outcome`, `params_kind`, `tool` |
58+| `openclaw_tool_execution_duration_seconds` | histogram | `error_category`, `outcome`, `params_kind`, `tool` |
59+| `openclaw_harness_run_total` | counter | `channel`, `error_category`, `harness`, `model`, `outcome`, `phase`, `plugin`, `provider` |
60+| `openclaw_harness_run_duration_seconds` | histogram | `channel`, `error_category`, `harness`, `model`, `outcome`, `phase`, `plugin`, `provider` |
61+| `openclaw_message_processed_total` | counter | `channel`, `outcome`, `reason` |
62+| `openclaw_message_processed_duration_seconds` | histogram | `channel`, `outcome`, `reason` |
63+| `openclaw_message_delivery_total` | counter | `channel`, `delivery_kind`, `error_category`, `outcome` |
64+| `openclaw_message_delivery_duration_seconds` | histogram | `channel`, `delivery_kind`, `error_category`, `outcome` |
65+| `openclaw_queue_lane_size` | gauge | `lane` |
66+| `openclaw_queue_lane_wait_seconds` | histogram | `lane` |
67+| `openclaw_session_state_total` | counter | `reason`, `state` |
68+| `openclaw_session_queue_depth` | gauge | `state` |
69+| `openclaw_memory_bytes` | gauge | `kind` |
70+| `openclaw_memory_rss_bytes` | histogram | none |
71+| `openclaw_memory_pressure_total` | counter | `level`, `reason` |
72+| `openclaw_telemetry_exporter_total` | counter | `exporter`, `reason`, `signal`, `status` |
73+| `openclaw_prometheus_series_dropped_total` | counter | none |
74+75+## Label policy
76+77+Prometheus labels stay bounded and low-cardinality. The exporter does not emit
78+raw diagnostic identifiers such as `runId`, `sessionKey`, `sessionId`, `callId`,
79+`toolCallId`, message IDs, chat IDs, or provider request IDs.
80+81+Label values are redacted and must match OpenClaw's low-cardinality character
82+policy. Values that fail the policy are replaced with `unknown`, `other`, or
83+`none`, depending on the metric.
84+85+The exporter caps retained time series in memory. If the cap is reached, new
86+series are dropped and `openclaw_prometheus_series_dropped_total` increments.
87+88+For full traces, logs, OTLP export, and OpenTelemetry GenAI semantic attributes,
89+use [OpenTelemetry export](/gateway/opentelemetry).
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。