How One Developer Built a Unified Grafana Dashboard to Track AI Token Costs
A homelab developer running three AI tools — Claude Code, Codex, and a custom alert-triage agent — found they had no visibility into combined token usage or costs across the setup. The three tools operate under different billing models: two use flat subscriptions measured in quota percentages, while the automated agent pays per token via a hosted API. To unify monitoring, the developer routed metrics from all three into Prometheus using separate collection methods — OpenTelemetry for Claude Code, a log-tailing Python exporter for the agent, and a Pushgateway timer for the mobile Codex CLI. Ollama, which lacks a native Prometheus endpoint, was handled by parsing its journald logs and polling its /api/ps endpoint via per-node exporters. The result is a single Grafana dashboard displaying token counts, latency, cache hits, quota burn rates, and real dollar spend across all AI workloads simultaneously.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in