<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Xuexue</title>
    <description>The latest articles on DEV Community by Xuexue (@aireet).</description>
    <link>https://dev.to/aireet</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3768919%2F86a194d6-6353-4ffc-956c-59bdae9bb928.jpeg</url>
      <title>DEV Community: Xuexue</title>
      <link>https://dev.to/aireet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aireet"/>
    <language>en</language>
    <item>
      <title>I Built an Exporter and Grafana Dashboard for Claude Code</title>
      <dc:creator>Xuexue</dc:creator>
      <pubDate>Thu, 12 Feb 2026 13:34:49 +0000</pubDate>
      <link>https://dev.to/aireet/i-built-an-exporter-and-grafana-dashboard-for-claude-code-3hpi</link>
      <guid>https://dev.to/aireet/i-built-an-exporter-and-grafana-dashboard-for-claude-code-3hpi</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;I use Claude Code daily, but I had no idea where my tokens were going. How many tokens per model? Which tools get called the&lt;br&gt;
  most? How active are my sessions?&lt;/p&gt;

&lt;p&gt;Claude Code stores usage data locally in &lt;code&gt;~/.claude&lt;/code&gt;, but it's raw JSON — not exactly easy to read.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;CC Exporter&lt;/strong&gt;: a Prometheus exporter that reads Claude Code's local data and exposes it as metrics, with a&lt;br&gt;
  pre-built Grafana dashboard for visualization.&lt;/p&gt;

&lt;p&gt;## Screenshots&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rntqwuh65p81wu5nog3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rntqwuh65p81wu5nog3.png" alt=" " width="800" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1gxjvz8kwh6fyg3qtpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1gxjvz8kwh6fyg3qtpz.png" alt=" " width="800" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;## What It Tracks&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Token usage by model&lt;/strong&gt; — input, output, cache read, cache creation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time active sessions&lt;/strong&gt; — live token counts, session count, message count&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Daily trends&lt;/strong&gt; — messages, sessions, tool calls, tokens over time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hourly activity&lt;/strong&gt; — see when you're most active&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool usage breakdown&lt;/strong&gt; — which tools (Read, Write, Bash, etc.) you use most&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Errors &amp;amp; retries&lt;/strong&gt; — API errors, retries, context compaction events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;## Quick Start&lt;/p&gt;

&lt;p&gt;### Full Stack (One Command)&lt;/p&gt;

&lt;p&gt;Deploy Exporter + Prometheus + Grafana with a pre-configured dashboard:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
  git clone https://github.com/aireet/cc-exporter.git
  cd cc-exporter
  ./start.sh

  Open http://localhost:3000/d/claude-token-monitor — login with admin / admin.
  ┌────────────┬───────────────────────────────┐
  │  Service   │              URL              │
  ├────────────┼───────────────────────────────┤
  │ Grafana    │ http://localhost:3000         │
  ├────────────┼───────────────────────────────┤
  │ Prometheus │ http://localhost:9099         │
  ├────────────┼───────────────────────────────┤
  │ Exporter   │ http://localhost:9101/metrics │
  └────────────┴───────────────────────────────┘
  Exporter Only (Docker Hub)

  Already have Prometheus and Grafana? Just run the exporter:

  docker run -d --name claude-exporter \
    -p 9101:9101 \
    -v ~/.claude:/data/claude:ro \
    -e CLAUDE_STATS_FILE=/data/claude/stats-cache.json \
    -e CLAUDE_DIR=/data/claude \
    xuexuexue1994/cc-exporter:latest

  Then add this to your Prometheus config:

  scrape_configs:
    - job_name: "claude-exporter"
      static_configs:
        - targets: ["localhost:9101"]

  And https://github.com/aireet/cc-exporter/blob/main/grafana/dashboards/claude-tokens.json into Grafana.

  Architecture

  ~/.claude (read-only)
      |
      +-- stats-cache.json ──→ ┌────────────┐   ┌────────────┐   ┌─────────┐
      +-- projects/*/?.jsonl → │  Exporter   │──→│ Prometheus │──→│ Grafana │
                                │ (Go, :9101) │   │  (:9099)   │   │ (:3000) │
                                └────────────┘   └────────────┘   └─────────┘

  - Exporter — Go binary that reads stats-cache.json (historical) + scans active JSONL files (real-time)
  - Prometheus — Scrapes every 30s, retains 90 days
  - Grafana — Pre-provisioned datasource and dashboard

  Data Safety

  - All Claude data is mounted as read-only
  - Everything stays on your machine — nothing is uploaded anywhere

  Links

  - GitHub: https://github.com/aireet/cc-exporter
  - Docker Hub: https://hub.docker.com/r/xuexuexue1994/cc-exporter
  - License: MIT

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>claude</category>
      <category>monitoring</category>
      <category>claudecode</category>
    </item>
  </channel>
</rss>
