---
title: "Measuring my own Claude Code usage with OpenTelemetry and Grafana"
description: "I count and mine my own Claude Code data with OpenTelemetry, Grafana and 88 days of session logs."
url: "https://michael.zazon.us/notes/measuring-my-own-claude-code-usage-with-opentelemetry-and-grafana"
published: "2026-11-04T12:00:00-05:00"
kind: "build-log"
subject: "ai-agents"
tags: ["claude","observability","ai-coding"]
series: "Coding agents"
part: 5
---
Claude Code runs on my home server for most of the day, across manual sessions, scheduled jobs, and autonomous agents. So knowing exactly how my usage of tokens and Claude Code impacts me is important.

This applies to enterprise usage as much as home usage.. I have many of the same questions a company rolling out coding agents would: what does the work consist of? What does it cost at list price? So I like to count and mine this data and do my own observability with Grafana and OpenTelemetry.

Claude Code exports its own OpenTelemetry metrics + events (see [monitoring docs](https://code.claude.com/docs/en/monitoring-usage)), so no instrumentation is needed. I send host sessions and NanoClaw agent containers to a collector, then to VictoriaMetrics, where Grafana reads them. The second source is session logs on disk, processed by a stats script.

[Diagram: Claude Code telemetry flowing to Grafana, and session logs feeding a stats script](https://michael.zazon.us/notes/measuring-my-own-claude-code-usage-with-opentelemetry-and-grafana)

My dashboard is "Claude Code Metrics" and has 35 panels.

- Sessions
- Cost and tokens
- Cache hit ratio
- Tool decisions
- Cost by model and effort level
- Scheduled, SDK and interactive work, side by side

[Image: Claude Code cost per hour by model, last 20 days](https://michael.zazon.us/notes/measuring-my-own-claude-code-usage-with-opentelemetry-and-grafana)

The first version looked fine when I was pushing synthetic metrics, but the first time I ran `claude -p` for real, nothing was kept (17 points accepted, 0 stored). It turned out that Claude Code defaults to delta temporality, and my metrics store was silently dropping the delta data. Now I always verify any telemetry change against a real session before I trust the dashboard.

A few days later, I removed the per-session ID label to reduce the number of series, accidentally collapsing all Claude Code processes into a single series where concurrent sessions' (and subagents') counters trampled each other. Suddenly the dashboard was showing cost/tokens inflated by 100 to 1,000 times.. $6,431 for a single six-hour window. I compared my setup to the public [agent-observability](https://github.com/KB1SLN-Labs/agent-observability) repo, which avoids this by keeping the session ID. After restoring it, the same view dropped to $2.76. I've kept the session ID ever since.

The third problem was query math, not data. For about two weeks in September, my [Sentinel](https://michael.zazon.us/notes/from-a-cron-job-to-sentinel) agent reused the same session ID across runs, so counters would rise and fall in turn. Grafana's `increase()` interpreted each drop as a reset, turning about $74 of actual spend into $120,000 to $600,000 a day.

The session logs tell me how I work, not how much I spend. They only go back 88 days, to early August, and that's the window I counted.. Claude Code first ran on this server back in late May. I prompted Claude Code on 84 of those 88 days, across 167 hands-on sessions (at least two prompts each). Another ~2,500 one-prompt runs came from scheduled and agent jobs, but those are separate and don't count toward the hands-on numbers. Bash accounts for about three quarters of tool calls in my main sessions, which makes sense given the shell-centred work I do in the [setup these numbers come from](https://michael.zazon.us/notes/my-claude-code-setup-one-chezmoi-source-for-every-machine) and how I [run several sessions at once](https://michael.zazon.us/notes/running-six-to-nine-claude-code-sessions-at-once).

It also tells me what I *don't* do.. plan mode never shows up in those 88 days, and compaction only happened 7 times. My most used skill is Brainstorming, followed by the skill that writes [handoffs](https://michael.zazon.us/notes/handoffs-and-carry-keeping-continuity-across-500-plus-sessions) at the end of a session.

I've transitioned away from using plan mode into structured planning sessions and very detailed notes organized into product or project folders with specs, designs, scratch space, architecture docs, and so on. I have good document hygiene, I use backlogs and task tracking, and I use Markdown for almost everything since it's portable and grep-able.

The cost figure is Claude Code's own estimate at API prices, not a bill. I'm on a subscription, but the equivalent API usage since I started recording in July is over $20,000, and that's an amazing deal for what Anthropic charges for this. The things I've done and built for myself I consider well worth the cost. And the fun factor, that is so much of it too.

One gap: the NanoClaw agents keep their transcripts inside their containers, so the session-log numbers only cover my own sessions. Next up.. [the agents that keep working when I'm away](https://michael.zazon.us/notes/agents-that-keep-working-when-i-close-the-laptop).