diagnostics-prometheus. Plugin này lắng nghe các chẩn đoán đáng tin cậy cùng các sự kiện ổn định Gateway do lõi phát ra, rồi kết xuất một điểm cuối văn bản Prometheus tại:
text/plain; version=0.0.4; charset=utf-8, định dạng trình bày tiêu chuẩn của Prometheus.
Đối với trace, log, OTLP push và các thuộc tính ngữ nghĩa OpenTelemetry GenAI, xem Xuất OpenTelemetry.
Bắt đầu nhanh
Scrape route được bảo vệ
Gửi cùng thông tin xác thực Gateway mà các máy khách người vận hành của bạn sử dụng:
Bắt buộc có
diagnostics.enabled: true. Nếu không có, Plugin vẫn đăng ký tuyến HTTP nhưng không có sự kiện chẩn đoán nào chảy vào exporter, nên phản hồi sẽ trống.Các metric được xuất
| Metric | Loại | Nhãn |
|---|---|---|
openclaw_run_completed_total | bộ đếm | channel, model, outcome, provider, trigger |
openclaw_run_duration_seconds | histogram | channel, model, outcome, provider, trigger |
openclaw_model_call_total | bộ đếm | api, error_category, model, outcome, provider, transport |
openclaw_model_call_duration_seconds | histogram | api, error_category, model, outcome, provider, transport |
openclaw_model_failover_total | bộ đếm | from_model, from_provider, lane, reason, suspended, to_model, to_provider |
openclaw_model_tokens_total | bộ đếm | agent, channel, model, provider, token_type |
openclaw_gen_ai_client_token_usage | histogram | model, provider, token_type |
openclaw_model_cost_usd_total | bộ đếm | agent, channel, model, provider |
openclaw_skill_used_total | bộ đếm | activation, agent, skill, source |
openclaw_tool_execution_total | bộ đếm | error_category, outcome, params_kind, tool, tool_owner, tool_source |
openclaw_tool_execution_duration_seconds | histogram | error_category, outcome, params_kind, tool, tool_owner, tool_source |
openclaw_tool_execution_blocked_total | bộ đếm | denied_reason, params_kind, tool, tool_owner, tool_source |
openclaw_harness_run_total | bộ đếm | 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_webhook_received_total | bộ đếm | channel, webhook |
openclaw_webhook_error_total | bộ đếm | channel, webhook |
openclaw_webhook_duration_seconds | histogram | channel, webhook |
openclaw_message_received_total | bộ đếm | channel, source |
openclaw_message_dispatch_started_total | bộ đếm | channel, source |
openclaw_message_dispatch_completed_total | bộ đếm | channel, outcome, reason, source |
openclaw_message_dispatch_duration_seconds | histogram | channel, outcome, reason, source |
openclaw_message_processed_total | bộ đếm | channel, outcome, reason |
openclaw_message_processed_duration_seconds | histogram | channel, outcome, reason |
openclaw_message_delivery_started_total | bộ đếm | channel, delivery_kind |
openclaw_message_delivery_total | bộ đếm | channel, delivery_kind, error_category, outcome |
openclaw_message_delivery_duration_seconds | histogram | channel, delivery_kind, error_category, outcome |
openclaw_talk_event_total | bộ đếm | brain, event_type, mode, provider, transport |
openclaw_talk_event_duration_seconds | histogram | brain, event_type, mode, provider, transport |
openclaw_talk_audio_bytes | histogram | brain, event_type, mode, provider, transport |
openclaw_queue_lane_size | gauge | lane |
openclaw_queue_lane_wait_seconds | histogram | lane |
openclaw_session_state_total | bộ đếm | reason, state |
openclaw_session_queue_depth | gauge | state |
openclaw_session_turn_created_total | bộ đếm | agent, channel, trigger |
openclaw_session_stuck_total | bộ đếm | reason, state |
openclaw_session_stuck_age_seconds | histogram | reason, state |
openclaw_session_recovery_total | bộ đếm | action, active_work_kind, state, status |
openclaw_session_recovery_age_seconds | histogram | action, active_work_kind, state, status |
openclaw_liveness_warning_total | bộ đếm | reason |
openclaw_liveness_sessions | gauge | state |
openclaw_liveness_event_loop_delay_p99_seconds | histogram | reason |
openclaw_liveness_event_loop_delay_max_seconds | histogram | reason |
openclaw_liveness_event_loop_utilization_ratio | histogram | reason |
openclaw_liveness_cpu_core_ratio | histogram | reason |
openclaw_payload_large_total | bộ đếm | action, channel, plugin, reason, surface |
openclaw_payload_large_bytes | histogram | action, channel, plugin, reason, surface |
openclaw_memory_bytes | gauge | kind |
openclaw_memory_rss_bytes | histogram | không có |
openclaw_memory_pressure_total | bộ đếm | level, reason |
openclaw_telemetry_exporter_total | bộ đếm | exporter, reason, signal, status |
openclaw_prometheus_series_dropped_total | bộ đếm | không có |
Chính sách nhãn
Bounded, low-cardinality labels
Bounded, low-cardinality labels
Nhãn Prometheus luôn có giới hạn và có số lượng giá trị thấp. Exporter không phát ra các định danh chẩn đoán thô như
runId, sessionKey, sessionId, callId, toolCallId, ID tin nhắn, ID cuộc trò chuyện, hoặc ID yêu cầu của provider.Giá trị nhãn được biên tập ẩn và phải khớp với chính sách ký tự số lượng giá trị thấp của OpenClaw. Các giá trị không đạt chính sách được thay bằng unknown, other, hoặc none, tùy theo metric. Các nhãn trông giống khóa phiên agent có phạm vi cũng được thay bằng unknown.Series cap and overflow accounting
Series cap and overflow accounting
Exporter giới hạn các chuỗi thời gian được giữ trong bộ nhớ ở mức 2048 chuỗi, tính gộp trên bộ đếm, gauge và histogram. Các chuỗi mới vượt quá giới hạn đó sẽ bị bỏ, và
openclaw_prometheus_series_dropped_total tăng thêm một mỗi lần.Theo dõi bộ đếm này như một tín hiệu chắc chắn rằng một thuộc tính thượng nguồn đang rò rỉ các giá trị có số lượng giá trị cao. Exporter không bao giờ tự động nâng giới hạn; nếu nó tăng, hãy sửa nguồn thay vì tắt giới hạn.Những gì không bao giờ xuất hiện trong đầu ra Prometheus
Những gì không bao giờ xuất hiện trong đầu ra Prometheus
- văn bản prompt, văn bản phản hồi, đầu vào công cụ, đầu ra công cụ, prompt hệ thống
- bản chép lời cuộc trò chuyện, tải trọng âm thanh, id cuộc gọi, id phòng, token chuyển giao, id lượt và id phiên thô
- ID yêu cầu nhà cung cấp thô (chỉ các hàm băm giới hạn, khi áp dụng, trên các span — không bao giờ trên metrics)
- khóa phiên và ID phiên
- tên máy chủ, đường dẫn tệp, giá trị bí mật
Công thức PromQL
Chọn giữa xuất Prometheus và OpenTelemetry
OpenClaw hỗ trợ cả hai bề mặt một cách độc lập. Bạn có thể chạy một trong hai, cả hai hoặc không chạy cái nào.- diagnostics-prometheus
- diagnostics-otel
- Mô hình pull: Prometheus thu thập
/api/diagnostics/prometheus. - Không cần collector bên ngoài.
- Được xác thực qua cơ chế xác thực Gateway thông thường.
- Bề mặt chỉ gồm metrics (không có trace hoặc log).
- Phù hợp nhất cho các stack đã chuẩn hóa trên Prometheus + Grafana.
Khắc phục sự cố
Nội dung phản hồi trống
Nội dung phản hồi trống
- Kiểm tra
diagnostics.enabled: truetrong cấu hình. - Xác nhận Plugin đã được bật và tải bằng
openclaw plugins list --enabled. - Tạo một ít lưu lượng; counter và histogram chỉ phát ra dòng sau ít nhất một sự kiện.
401 / không được ủy quyền
401 / không được ủy quyền
Endpoint yêu cầu phạm vi toán tử Gateway (
auth: "gateway" với gatewayRuntimeScopeSurface: "trusted-operator"). Dùng cùng token hoặc mật khẩu mà Prometheus dùng cho bất kỳ tuyến toán tử Gateway nào khác. Không có chế độ công khai không xác thực.`openclaw_prometheus_series_dropped_total` đang tăng
`openclaw_prometheus_series_dropped_total` đang tăng
Một thuộc tính mới đang vượt quá giới hạn 2048 chuỗi. Kiểm tra metrics gần đây để tìm nhãn có cardinality cao bất thường và khắc phục tại nguồn. Exporter cố ý bỏ các chuỗi mới thay vì âm thầm ghi lại nhãn.
Prometheus hiển thị chuỗi cũ sau khi khởi động lại
Prometheus hiển thị chuỗi cũ sau khi khởi động lại
Plugin chỉ giữ trạng thái trong bộ nhớ. Sau khi Gateway khởi động lại, counter đặt lại về 0 và gauge bắt đầu lại ở giá trị được báo cáo tiếp theo. Dùng PromQL
rate() và increase() để xử lý việc đặt lại một cách gọn gàng.Liên quan
- Xuất chẩn đoán — tệp zip chẩn đoán cục bộ cho gói hỗ trợ
- Sức khỏe và sẵn sàng — probe
/healthzvà/readyz - Ghi log — ghi log dựa trên tệp
- Xuất OpenTelemetry — đẩy OTLP cho trace, metrics và log