diagnostics-prometheus Plugin を通じて診断メトリクスを公開できます。この Plugin は信頼された内部診断を監視し、次の場所に Prometheus テキストエンドポイントを出力します。
text/plain; version=0.0.4; charset=utf-8 で、標準の Prometheus exposition format です。
トレース、ログ、OTLP push、OpenTelemetry GenAI セマンティック属性については OpenTelemetry export を参照してください。
クイックスタート
diagnostics.enabled: true が必要です。これがないと、Plugin は HTTP ルート自体は登録しますが、エクスポーターに診断イベントが流れないため、レスポンスは空になります。エクスポートされるメトリクス
| メトリクス | 種別 | ラベル |
|---|---|---|
openclaw_run_completed_total | counter | channel, model, outcome, provider, trigger |
openclaw_run_duration_seconds | histogram | channel, model, outcome, provider, trigger |
openclaw_model_call_total | counter | api, error_category, model, outcome, provider, transport |
openclaw_model_call_duration_seconds | histogram | api, error_category, model, outcome, provider, transport |
openclaw_model_tokens_total | counter | agent, channel, model, provider, token_type |
openclaw_gen_ai_client_token_usage | histogram | model, provider, token_type |
openclaw_model_cost_usd_total | counter | agent, channel, model, provider |
openclaw_tool_execution_total | counter | error_category, outcome, params_kind, tool |
openclaw_tool_execution_duration_seconds | histogram | error_category, outcome, params_kind, tool |
openclaw_harness_run_total | counter | channel, error_category, harness, model, outcome, phase, plugin, provider |
openclaw_harness_run_duration_seconds | histogram | channel, error_category, harness, model, outcome, phase, plugin, provider |
openclaw_message_processed_total | counter | channel, outcome, reason |
openclaw_message_processed_duration_seconds | histogram | channel, outcome, reason |
openclaw_message_delivery_total | counter | channel, delivery_kind, error_category, outcome |
openclaw_message_delivery_duration_seconds | histogram | channel, delivery_kind, error_category, outcome |
openclaw_queue_lane_size | gauge | lane |
openclaw_queue_lane_wait_seconds | histogram | lane |
openclaw_session_state_total | counter | reason, state |
openclaw_session_queue_depth | gauge | state |
openclaw_memory_bytes | gauge | kind |
openclaw_memory_rss_bytes | histogram | なし |
openclaw_memory_pressure_total | counter | level, reason |
openclaw_telemetry_exporter_total | counter | exporter, reason, signal, status |
openclaw_prometheus_series_dropped_total | counter | なし |
ラベルポリシー
制限された低カーディナリティのラベル
制限された低カーディナリティのラベル
Prometheus ラベルは、制限され低カーディナリティに保たれます。エクスポーターは
runId、sessionKey、sessionId、callId、toolCallId、message ID、chat ID、provider request ID などの生の診断識別子を出力しません。ラベル値は redaction され、OpenClaw の低カーディナリティ文字ポリシーに一致する必要があります。ポリシーに合わない値は、メトリクスに応じて unknown、other、none に置き換えられます。シリーズ上限とオーバーフロー計上
シリーズ上限とオーバーフロー計上
エクスポーターは、保持するインメモリ時系列を counter、gauge、histogram の合計で 2048 シリーズに制限します。その上限を超える新しいシリーズは破棄され、
openclaw_prometheus_series_dropped_total が毎回 1 ずつ増加します。これは、上流の属性が高カーディナリティ値を漏らしていることを示す強いシグナルとして監視してください。エクスポーターが自動的に上限を引き上げることはありません。増加している場合は、上限を無効化するのではなくソースを修正してください。Prometheus 出力に絶対に現れないもの
Prometheus 出力に絶対に現れないもの
- プロンプトテキスト、レスポンステキスト、ツール入力、ツール出力、システムプロンプト
- 生の provider request ID(span 上では適用可能な場合に限り制限付きハッシュのみ。メトリクスには決して出ません)
- セッションキーとセッション ID
- ホスト名、ファイルパス、シークレット値
PromQL レシピ
Prometheus と OpenTelemetry export のどちらを選ぶか
OpenClaw は両方のサーフェスを独立してサポートします。どちらか一方、両方、またはどちらも使わないことができます。- diagnostics-prometheus
- diagnostics-otel
- Pull モデル: Prometheus が
/api/diagnostics/prometheusを scrape します。 - 外部コレクター不要。
- 通常の Gateway 認証を通じて認証されます。
- サーフェスはメトリクスのみです(トレースやログはなし)。
- すでに Prometheus + Grafana を標準化しているスタックに最適です。
トラブルシューティング
レスポンスボディが空
レスポンスボディが空
- config で
diagnostics.enabled: trueを確認してください。 openclaw plugins list --enabledで Plugin が有効かつロードされていることを確認してください。- 何らかのトラフィックを発生させてください。counter と histogram は少なくとも 1 件のイベント後にしか行を出力しません。
401 / unauthorized
401 / unauthorized
`openclaw_prometheus_series_dropped_total` が増え続ける
`openclaw_prometheus_series_dropped_total` が増え続ける
新しい属性が 2048 シリーズ上限を超えています。最近のメトリクスを調べて、予想外に高カーディナリティなラベルを見つけ、ソース側で修正してください。エクスポーターはラベルを書き換えてごまかすのではなく、意図的に新しいシリーズを破棄します。
Prometheus に再起動後の古いシリーズが残る
Prometheus に再起動後の古いシリーズが残る
Plugin は状態をメモリ内にのみ保持します。Gateway 再起動後、counter はゼロに戻り、gauge は次に報告された値から再開します。リセットをきれいに扱うには PromQL の
rate() と increase() を使ってください。関連
- 診断エクスポート — サポートバンドル用のローカル診断 zip
- ヘルスと readiness —
/healthzと/readyzプローブ - ロギング — ファイルベースのロギング
- OpenTelemetry export — トレース、メトリクス、ログ用の OTLP push