Claude Code

Claude Code Prometheus Monitoring

Monitor Claude Code metrics with Prometheus.

Route OpenTelemetry metrics into Prometheus-compatible storage and create actionable cost and usage alerts.

In brief

Claude Code metrics can be routed through an OpenTelemetry collector to a Prometheus-compatible backend. Use low-cardinality labels for durable dashboards and keep user-level detail in access-controlled views.

Metric design

Cardinality and identity strategy determine whether the monitoring system remains reliable and affordable.

  • Keep team and model labels bounded
  • Avoid repository paths as unrestricted labels
  • Record user detail only where required
  • Use recording rules for dashboard queries
  • Define retention by operational need

Useful alerts

Alert on conditions that require action rather than every usage spike.

  • Unexpected cost acceleration
  • Telemetry pipeline outage
  • Sustained cache-efficiency decline
  • Abnormal retry or session patterns
  • Budget threshold by team

FAQ

Does Prometheus scrape Claude Code directly?

A collector-based design is generally easier to govern: Claude Code exports telemetry, the collector processes it and Prometheus stores or scrapes the resulting metrics endpoint.

Should developer email be a Prometheus label?

Prefer a stable pseudonymous identifier or team aggregation. Personal identifiers create privacy and cardinality concerns.