ในหน้านี้
ในหน้านี้
Gateway
เมตริก Prometheus
OpenClaw สามารถเปิดเผยเมตริกการวินิจฉัยผ่าน Plugin อย่างเป็นทางการ
diagnostics-prometheus โดยรับข้อมูลการวินิจฉัยที่เชื่อถือได้ รวมถึง
เหตุการณ์การวินิจฉัยที่ติดแท็กภายในและอยู่ภายใต้การจัดการของตัวกระจายงาน (สัญญาณคิว หน่วยความจำ และ
การกู้คืนเซสชัน) แล้วแสดงผลปลายทางข้อความ Prometheus ที่:
ชนิดเนื้อหาคือ text/plain; version=0.0.4; charset=utf-8 ซึ่งเป็นรูปแบบ
การเปิดเผยข้อมูลมาตรฐานของ Prometheus
สำหรับเทรซ บันทึก การพุช OTLP และแอตทริบิวต์เชิงความหมาย GenAI ของ OpenTelemetry โปรดดู การส่งออก OpenTelemetry
เริ่มต้นอย่างรวดเร็ว
ติดตั้ง Plugin
เปิดใช้งาน Plugin
การกำหนดค่า
CLI
รีสตาร์ต Gateway
เส้นทาง HTTP จะลงทะเบียนเมื่อ Plugin เริ่มทำงาน ดังนั้นให้โหลดใหม่หลังจากเปิดใช้งาน
ดึงข้อมูลจากเส้นทางที่มีการป้องกัน
ส่งข้อมูลการยืนยันตัวตนของ Gateway แบบเดียวกับที่ไคลเอ็นต์ผู้ปฏิบัติงานใช้:
เชื่อมต่อ Prometheus
เมตริกที่ส่งออก
| เมตริก | ชนิด | ป้ายกำกับ |
|---|---|---|
openclaw_run_completed_total |
ตัวนับ | channel, model, outcome, provider, trigger |
openclaw_run_duration_seconds |
ฮิสโตแกรม | channel, model, outcome, provider, trigger |
openclaw_model_call_total |
ตัวนับ | api, error_category, model, observation_unit, outcome, provider, transport |
openclaw_model_call_duration_seconds |
ฮิสโตแกรม | api, error_category, model, observation_unit, outcome, provider, transport |
openclaw_model_failover_total |
ตัวนับ | from_model, from_provider, lane, reason, suspended, to_model, to_provider |
openclaw_model_tokens_total |
ตัวนับ | agent, channel, model, provider, token_type |
openclaw_gen_ai_client_token_usage |
ฮิสโตแกรม | model, provider, token_type |
openclaw_model_cost_usd_total |
ตัวนับ | agent, channel, model, provider |
openclaw_model_usage_duration_seconds |
ฮิสโตแกรม | agent, channel, model, provider |
openclaw_skill_used_total |
ตัวนับ | activation, agent, skill, source |
openclaw_tool_execution_total |
ตัวนับ | error_category, outcome, params_kind, tool, tool_owner, tool_source |
openclaw_tool_execution_duration_seconds |
ฮิสโตแกรม | error_category, outcome, params_kind, tool, tool_owner, tool_source |
openclaw_tool_execution_blocked_total |
ตัวนับ | denied_reason, params_kind, tool, tool_owner, tool_source |
openclaw_harness_run_total |
ตัวนับ | channel, error_category, harness, model, outcome, phase, plugin, provider |
openclaw_harness_run_duration_seconds |
ฮิสโตแกรม | channel, error_category, harness, model, outcome, phase, plugin, provider |
openclaw_webhook_received_total |
ตัวนับ | channel, webhook |
openclaw_webhook_error_total |
ตัวนับ | channel, webhook |
openclaw_webhook_duration_seconds |
ฮิสโตแกรม | channel, webhook |
openclaw_message_received_total |
ตัวนับ | channel, source |
openclaw_message_dispatch_started_total |
ตัวนับ | channel, source |
openclaw_message_dispatch_completed_total |
ตัวนับ | channel, outcome, reason, source |
openclaw_message_dispatch_duration_seconds |
ฮิสโตแกรม | channel, outcome, reason, source |
openclaw_message_processed_total |
ตัวนับ | channel, outcome, reason |
openclaw_message_processed_duration_seconds |
ฮิสโตแกรม | channel, outcome, reason |
openclaw_message_delivery_started_total |
ตัวนับ | channel, delivery_kind |
openclaw_message_delivery_total |
ตัวนับ | channel, delivery_kind, error_category, outcome |
openclaw_message_delivery_duration_seconds |
ฮิสโตแกรม | channel, delivery_kind, error_category, outcome |
openclaw_talk_event_total |
ตัวนับ | brain, event_type, mode, provider, transport |
openclaw_talk_event_duration_seconds |
ฮิสโตแกรม | brain, event_type, mode, provider, transport |
openclaw_talk_audio_bytes |
ฮิสโตแกรม | brain, event_type, mode, provider, transport |
openclaw_queue_lane_size |
เกจ | lane |
openclaw_queue_lane_wait_seconds |
ฮิสโตแกรม | lane |
openclaw_session_state_total |
ตัวนับ | reason, state |
openclaw_session_queue_depth |
เกจ | state |
openclaw_session_turn_created_total |
ตัวนับ | agent, channel, trigger |
openclaw_session_stuck_total |
ตัวนับ | reason, state |
openclaw_session_stuck_age_seconds |
ฮิสโตแกรม | reason, state |
openclaw_session_recovery_total |
ตัวนับ | action, active_work_kind, state, status |
openclaw_session_recovery_age_seconds |
ฮิสโตแกรม | action, active_work_kind, state, status |
openclaw_liveness_warning_total |
ตัวนับ | reason |
openclaw_liveness_sessions |
เกจ | state |
openclaw_liveness_event_loop_delay_p99_seconds |
ฮิสโตแกรม | reason |
openclaw_liveness_event_loop_delay_max_seconds |
ฮิสโตแกรม | reason |
openclaw_liveness_event_loop_utilization_ratio |
ฮิสโตแกรม | reason |
openclaw_liveness_cpu_core_ratio |
ฮิสโตแกรม | reason |
openclaw_payload_large_total |
ตัวนับ | action, channel, plugin, reason, surface |
openclaw_payload_large_bytes |
ฮิสโตแกรม | action, channel, plugin, reason, surface |
openclaw_memory_bytes |
เกจ | kind |
openclaw_memory_rss_bytes |
ฮิสโตแกรม | ไม่มี |
openclaw_memory_pressure_total |
ตัวนับ | level, reason |
openclaw_telemetry_exporter_total |
ตัวนับ | exporter, reason, signal, status |
openclaw_prometheus_series_dropped_total |
ตัวนับ | ไม่มี |
openclaw_diagnostic_async_queue_dropped_total |
ตัวนับ | drop_class |
openclaw_diagnostic_async_queue_length |
เกจ | ไม่มี |
สำหรับเมตริกการเรียกโมเดล observation_unit="request" วัดคำขอไปยังผู้ให้บริการที่สังเกตได้หนึ่งครั้ง
ส่วน observation_unit="turn" วัดหนึ่งรอบการทำงานของเอเจนต์ Claude Code
หรือ Codex CLI แบบสังเคราะห์ ซึ่งอาจมีคำขอไปยังผู้ให้บริการที่ซ่อนอยู่หลายครั้ง
ให้แยกอนุกรมเหล่านี้ออกจากกันเมื่อเปรียบเทียบเวลาแฝง
นโยบายป้ายกำกับ
ป้ายกำกับที่มีขอบเขตและคาร์ดินาลิตีต่ำ
ป้ายกำกับ Prometheus จะมีขอบเขตและคาร์ดินาลิตีต่ำ ตัวส่งออกจะไม่ส่งตัวระบุการวินิจฉัยดิบ เช่น runId, sessionKey, sessionId, callId, toolCallId, ID ข้อความ, ID แชต หรือ ID คำขอของผู้ให้บริการ
ค่าป้ายกำกับจะถูกปกปิดและต้องเป็นไปตามนโยบายอักขระแบบคาร์ดินาลิตีต่ำของ OpenClaw ค่าที่ไม่ผ่านนโยบายจะถูกแทนที่ด้วย unknown, other หรือ none ตามเมตริก ป้ายกำกับที่มีลักษณะคล้ายคีย์เซสชันของเอเจนต์แบบมีขอบเขตจะถูกแทนที่ด้วย unknown เช่นกัน
ขีดจำกัดอนุกรมและการนับส่วนที่เกิน
ตัวส่งออกจำกัดอนุกรมเวลาที่เก็บไว้ในหน่วยความจำไว้ที่ 2048 อนุกรม โดยนับรวมตัวนับ เกจ และฮิสโตแกรม อนุกรมใหม่ที่เกินขีดจำกัดนี้จะถูกทิ้ง และ openclaw_prometheus_series_dropped_total จะเพิ่มขึ้นหนึ่งทุกครั้ง
ให้เฝ้าดูตัวนับนี้ในฐานะสัญญาณที่ชัดเจนว่าแอตทริบิวต์ต้นทางกำลังปล่อยค่าที่มีคาร์ดินาลิตีสูงออกมา ตัวส่งออกจะไม่เพิ่มขีดจำกัดโดยอัตโนมัติ หากตัวนับเพิ่มขึ้น ให้แก้ไขที่ต้นทางแทนการปิดใช้งานขีดจำกัด
สิ่งที่ไม่ปรากฏในเอาต์พุต Prometheus
- ข้อความพรอมต์ ข้อความตอบกลับ อินพุตของเครื่องมือ เอาต์พุตของเครื่องมือ พรอมต์ระบบ
- ทรานสคริปต์การสนทนา เพย์โหลดเสียง ID การโทร ID ห้อง โทเค็นส่งต่อ ID รอบการทำงาน และ ID เซสชันดิบ
- ID คำขอของผู้ให้บริการแบบดิบ (มีเฉพาะแฮชที่มีขอบเขต หากใช้ บนสแปนเท่านั้น — ไม่อยู่ในเมตริก)
- คีย์เซสชันและ ID เซสชัน
- ชื่อโฮสต์ พาธไฟล์ ค่าความลับ
สูตร PromQL
การเลือกระหว่างการส่งออก Prometheus และ OpenTelemetry
OpenClaw รองรับทั้งสองพื้นผิวอย่างเป็นอิสระจากกัน สามารถใช้อย่างใดอย่างหนึ่ง ใช้ทั้งคู่ หรือไม่ใช้เลยก็ได้
diagnostics-prometheus
- โมเดล ดึง: Prometheus ดึงข้อมูลจาก
/api/diagnostics/prometheus - ไม่จำเป็นต้องมีตัวรวบรวมภายนอก
- ตรวจสอบสิทธิ์ผ่านการตรวจสอบสิทธิ์ตามปกติของ Gateway
- พื้นผิวนี้มีเฉพาะเมตริกเท่านั้น (ไม่มีเทรซหรือบันทึก)
- เหมาะที่สุดสำหรับสแต็กที่กำหนดมาตรฐานไว้แล้วบน Prometheus + Grafana
diagnostics-otel
- โมเดล ส่ง: OpenClaw ส่ง OTLP/HTTP ไปยังตัวรวบรวมหรือแบ็กเอนด์ที่เข้ากันได้กับ OTLP
- พื้นผิวนี้ประกอบด้วยเมตริก เทรซ และบันทึก
- เชื่อมต่อไปยัง Prometheus ผ่าน OpenTelemetry Collector (ตัวส่งออก
prometheusหรือprometheusremotewrite) เมื่อต้องใช้ทั้งสองอย่าง - ดูแค็ตตาล็อกฉบับเต็มได้ที่ การส่งออก OpenTelemetry
การแก้ไขปัญหา
เนื้อหาการตอบกลับว่างเปล่า
- ตรวจสอบว่าไม่ได้ตั้งค่า
diagnostics.enabledเป็นfalseในการกำหนดค่า (ค่าเริ่มต้นคือtrue) - ยืนยันว่า Plugin เปิดใช้งานและโหลดแล้วด้วย
openclaw plugins list --enabled - สร้างทราฟฟิกบางส่วน ตัวนับและฮิสโตแกรมจะส่งบรรทัดออกมาหลังจากเกิดเหตุการณ์อย่างน้อยหนึ่งครั้งเท่านั้น
401 / ไม่ได้รับอนุญาต
เอนด์พอยต์ต้องใช้ขอบเขตผู้ควบคุม Gateway (auth: "gateway" พร้อม gatewayRuntimeScopeSurface: "trusted-operator") ใช้โทเค็นหรือรหัสผ่านเดียวกับที่ Prometheus ใช้สำหรับเส้นทางผู้ควบคุม Gateway อื่น ๆ ไม่มีโหมดสาธารณะที่ไม่ต้องตรวจสอบสิทธิ์
`openclaw_prometheus_series_dropped_total` กำลังเพิ่มขึ้น
แอตทริบิวต์ใหม่กำลังทำให้เกินขีดจำกัด 2048 อนุกรม ตรวจสอบเมตริกล่าสุดเพื่อหาป้ายกำกับที่มีคาร์ดินาลิตีสูงเกินคาดและแก้ไขที่ต้นทาง ตัวส่งออกตั้งใจทิ้งอนุกรมใหม่แทนการเขียนป้ายกำกับใหม่โดยไม่แจ้ง
Prometheus แสดงอนุกรมเก่าหลังจากรีสตาร์ต
Plugin เก็บสถานะไว้ในหน่วยความจำเท่านั้น หลังรีสตาร์ต Gateway ตัวนับจะรีเซ็ตเป็นศูนย์ และเกจจะเริ่มใหม่ด้วยค่าที่รายงานครั้งถัดไป ใช้ PromQL rate() และ increase() เพื่อจัดการการรีเซ็ตอย่างถูกต้อง
เนื้อหาที่เกี่ยวข้อง
- การส่งออกข้อมูลวินิจฉัย — ไฟล์ zip การวินิจฉัยภายในเครื่องสำหรับชุดข้อมูลสนับสนุน
- สถานะความสมบูรณ์และความพร้อม — โพรบ
/healthzและ/readyz - การบันทึก — การบันทึกลงไฟล์
- การส่งออก OpenTelemetry — การส่งแบบพุชผ่าน OTLP สำหรับเทรซ เมตริก และบันทึก