Grafana & OpenTelemetry
Navigator’s efficiency story is backed by real session telemetry, not estimates. Claude Code can export metrics over OpenTelemetry, and Navigator reads them to report what actually happened in your session.
The principle: measure your own sessions, don’t trust the headline numbers. Any figures below are example output.
Enabling telemetry
Claude Code exports metrics when OpenTelemetry is turned on. Since v8.4.0 Navigator documents one setup: OTLP to the collector that ships in .agent/grafana/. Put the block in ~/.claude/settings.json; it applies to every project and overrides the same variables exported by your shell.
{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4318",
"OTEL_METRIC_EXPORT_INTERVAL": "10000"
}
}Then start the stack and restart your Claude Code sessions:
cd .agent/grafana && docker compose up -d
curl -s http://localhost:8889/metrics | grep -o 'session_id="[^"]*"' | sort -u # one line per sessionWhy not OTEL_METRICS_EXPORTER=prometheus? That exporter makes each Claude Code process serve one fixed port, 9464. Only the first process binds it; every later session exports nothing, silently, and the dashboard and the /nav session card show $0.00 for the day. The collector accepts any number of sessions on one endpoint. If the variable is still set, session start prints Metrics: prometheus exporter is single-session (port 9464); switch to otlp.
With telemetry enabled, Claude Code emits session metrics that Navigator reads back through nav-stats, the /nav pane and the dashboard.
What’s available
Navigator’s stats pipeline (scripts/session-stats.sh) draws on both .agent/ doc sizing and OpenTelemetry data:
- Token usage — documentation loaded vs. the baseline of loading everything
- Cache hit rate — prompt cache efficiency, read from OpenTelemetry
- Cost — session spend, when exported by Claude Code
- Active time — time saved estimates derived from token deltas
- Context availability — how much of the context window remains for work
Surfacing the metrics
Run the efficiency report on demand:
"Show my stats" → nav-statsExample output (your numbers will differ):
💾 CACHE PERFORMANCE
Cache efficiency: 100.0% (perfect)
📈 SESSION METRICS
Context usage: 35% (excellent)
Efficiency score: 94/100 (excellent)nav-stats reads cache efficiency from OpenTelemetry, computes token savings from your actual doc footprint, and turns them into a score with actionable recommendations. nav-start can also surface a quick read at session start.
The bundled stack
.agent/grafana/ (copied into every project by nav-init) holds a docker-compose.yml with three services:
| Service | Ports | Role |
|---|---|---|
| OpenTelemetry Collector | 4318 (OTLP http), 4317 (grpc), 8889 (scrape) | Receives every session’s metrics; re-exposes them for Prometheus with the metric names Claude Code’s own exporter used (claude_code_cost_usage_total, claude_code_token_usage_total, …) |
| Prometheus | 9092 | Scrapes the collector every 15 s; 7-day retention. The legacy direct exporter on :9464 stays as job claude-code-direct |
| Grafana | 3333 | A provisioned 13-panel dashboard: cache hit rate, cache savings, tokens, cost, commits, lines, active time, model split |
Claude Code sends delta counters over OTLP; the collector accumulates them per series and keeps a quiet session’s running total for 48 hours, so an overnight pause does not reset a counter. The /nav pane reads the same Prometheus: per-series maximum in the window minus the last sample before it, which is why counters must not reset.
Because the data is standard OpenTelemetry, you can also point the exporter at any other OTLP backend. Navigator does not require the stack; without it the /nav session card shows Claude Code’s own numbers.