oscarabal

Claude Metrics — Development skill for Claude Code

Development community

A local observability stack for Claude Code.

How to install Claude Metrics

This entry records only its repository, not the path inside it, so there is no exact command to give. Open oscarabal/claude-metrics and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Metrics does

A local observability stack for [Claude Code](https://claude.com/claude-code). Claude Code exports OpenTelemetry metrics and events; this stack stores them and draws a Grafana dashboard that shows how many tokens are consumed, how much they cost, who uses them and which prompts, tools and skills drive the cost.

Alternatives in Development

  • Metrics Dashboard — Define product metrics dashboard with sources and alert thresholds 7.8k ★
  • Mulmoterminal — Run multiple Claude Code and Codex sessions in parallel — a browser terminal grid that shows which agent needs 187 ★
  • V Dashboard — Open the Compound V observability dashboard — a present-only, read-only browser view over docs/superpowers/exe 35 ★

README

Claude Code metrics

[Español](README.es.md)

A local observability stack for [Claude Code](https://claude.com/claude-code). Claude Code exports OpenTelemetry metrics and events; this stack stores them and draws a Grafana dashboard that shows how many tokens are consumed, how much they cost, who uses them and which prompts, tools and skills drive the cost.

Everything runs with Docker Compose on one machine.

Architecture

flowchart LR
    CC[Claude Code] -- "OTLP/gRPC" --> COL[OpenTelemetry Collector]
    COL -- metrics --> PROM[(Prometheus)]
    COL -- events --> LOKI[(Loki)]
    FILES["~/.claude/projects"] -- read-only --> SM[session-map]
    SM -- "session → project, context, skills" --> PROM
    LOKI -- "cost by request id" --> SM
    PROM --> GRA[Grafana]
    LOKI --> GRA
    GRA -. "session links" .-> SM
Service Role Port Storage
otel-collector Receives OTLP, exposes metrics for Prometheus, forwards events to Loki 4317 (gRPC), 4318 (HTTP), 8889 (metrics) none
prometheus Stores metrics and answers PromQL 9090 volume prometheus-data, 90 days
loki Stores events and answers LogQL 3100 volume loki-data, 30 days
session-map Publishes which project each session belongs to and what its conversations show, and serves the session pages 127.0.0.1:9100 none
grafana Dashboards 3000 volume grafana-data

Why `session-map`

The Claude Code desktop app ignores `OTEL_RESOURCE_ATTRIBUTES`, so its sessions arrive without a `project` label. `session-map/map.py` reads the folder names under `~/.claude/projects` (read-only) and publishes `claude_session_project{session_id, project}`. Both dashboards filter by `session_id` through a hidden `sessions` variable, so CLI and desktop sessions, including past ones, are attributed to a project.

The project name comes from the working directory each session recorded (`cwd`), in lower case: its last folder, so `C:\d