A fully local metrics pipeline for Claude Code and OpenAI Codex CLI that ingests OTLP telemetry through an OpenTelemetry Collector into Prometheus and Grafana for unified monitoring.

Stars

6

7-day growth

No data

Forks

0

Open issues

0

License

MIT

Last updated

2026-07-28

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It unifies token, cost, and productivity metrics from two major AI coding assistants into one self-hosted stack with automated Grafana dashboards and strict privacy filtering.

Who it is for

  • Developers using Claude Code and/or Codex CLI
  • Engineering teams wanting local observability of AI coding tool usage
  • Platform engineers managing cost and resource tracking for AI assistants
  • Security-conscious users who prefer not to send metrics to external services

Use cases

  • Track token consumption and estimated cost across both Claude Code and Codex CLI in a single dashboard
  • Compare provider-emitted cost estimates vs list-price equivalents
  • Monitor named agent activity and its share of token usage
  • Measure coding productivity indicators such as commits and lines changed

Strengths

  • Fully local operation with published ports defaulting to loopback, keeping data on the machine
  • Automatically provisioned Grafana dashboard with five rows covering overview, token usage, cost, agents, and sessions
  • Privacy-first design: collector strips session IDs, account IDs, and other identities before data reaches Prometheus
  • Supports concurrency safety with delta compaction and lock-file serialization for hooks and stack scripts

Considerations

  • Metrics are best-effort observability, not financial exactness — no exactly-once delivery or crash-safe batches
  • Requires specific client versions (Claude Code ≥2.1.214, Codex CLI ≥0.145.0) and runs only on macOS or Ubuntu
  • No built-in authentication for Prometheus or collector; Grafana password protects only Grafana

README quick start

cc-metrics

Local metrics pipeline for Claude Code and OpenAI Codex CLI:

Claude Code ─┐
             ├─ OTLP ─> OpenTelemetry Collector ─> Prometheus ─> Grafana
Codex CLI ───┘

Runs entirely on your machine. Published ports bind to 127.0.0.1 by default. Client authentication stays in Claude Code or Codex; this stack needs no provider API key.

Dashboard

One Grafana dashboard, "Token & Usage Monitor", provisioned automatically. Five rows:

rowwhat it answers
Overviewsession starts, tokens, estimated cost, Codex threads, active time, cache hit rate
Token Usagetokens over time, split by type, model, and Claude effort level
Cost Analysisestimated cost over time and by model, across both vendors
Agentstokens and estimated cost for Claude traffic carrying a named agent
Sessions & Productivitycommits, pull requests, lines changed, edit decisions

Cost split by model across both vendors is the reason this exists rather than either vendor's own view. Claude figures are the provider's own estimates; Codex figures are list-price estimates computed here — see Cost meaning for what that difference implies.

Overview headline tiles:

Token usage over the selected range, split by token type:

The Codex side of the cost split, priced from the list-price rules:

Named-agent attribution — the share of Claude tokens carrying an agent name, and its split by agent type:

Every panel is empty until a client sends data. Setup steps 3 and 4 do that.

Features

  • Claude Code and Codex token views under one ai_* metric namespace.
  • Provider-emitted Claude cost estimates.
  • Standard OpenAI API list-price estimates for selected Codex models.
  • Configurable host ports, environment label, retention, and image references.
  • Optional, forward-looking Codex commit counter.
  • Prometheus rule, dashboard contract, hook, pricing, and hygiene tests.

Requirements

ComponentSupported requirement
HostmacOS or Ubuntu only
ContainersDocker with docker compose
Claude Code2.1.214 or newer for corrected streaming token/cost accounting
Codex CLI0.145.0 or newer for GPT-5.6 cache-write telemetry
Python3.10 or newer for hook installation, pricing maintenance, and tests
GitNeeded for cloning and the optional commit metric
Password g

Related repositories

Similar projects matched by category, topics, and programming language.

lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,390
slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960
littledivy
Featured
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI & Machine Learning
1,482