Cc Metrics banner
alonw0 alonw0

Cc Metrics

Development community

Description

A Grafana dashboard for Claude Code otel metrics (dockerized)

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Claude Code Metrics Dashboard

A comprehensive monitoring stack for tracking Claude Code usage metrics, costs, and performance using OpenTelemetry, Prometheus, and Grafana.

Based on the [Sealos blog post](https://sealos.io/blog/claude-code-metrics).

Features

  • Real-time Metrics Tracking: Monitor Claude Code sessions, token usage, costs, commits, and more
  • Comprehensive Dashboard: 20+ panels showing key metrics, efficiency gauges, trends, and distributions
  • Cost Analysis: Track costs by model, session, and time period
  • Cache Efficiency Monitoring: Visualize prompt caching effectiveness
  • Productivity Insights: Measure CLI vs user active time ratios
  • Auto-provisioning: Dashboard and datasources automatically configured on startup

Architecture

Claude Code
    ↓ (OTLP HTTP/gRPC - metrics + logs)
OpenTelemetry Collector (:4318/:4317)
    ├─→ Prometheus metrics (:8889)
    │       ↓
    │   Prometheus (:9090)
    └─→ JSON logs (file)
            ↓
        Promtail
            ↓
        Loki (:3100)
            ↓ (PromQL + LogQL queries)
        Grafana (:3000)
            ↓ (Dashboard visualization)
        Your Browser

Metrics Tracked

  • Sessions: Total Claude Code session starts
  • Tokens: Usage by type (input, output, cache_read, cache_creation) and model
  • Costs: Estimated USD costs with per-model breakdown
  • Code Changes: Lines added/removed from accepted edits
  • Git Activity: Commits and pull requests created
  • Edit Decisions: Accept/reject choices on code suggestions
  • Active Time: User input time vs CLI processing time
  • Prompt Length: Average character count of user prompts (via Loki logs)

Prerequisites

  • Docker and Docker Compose
  • Claude Code CLI

Quick Start

1. Clone or Download This Repository

cd cc-metrics

2. Set Up Data Directories

make setup

Or manually:

mkdir -p data/prometheus data/grafana data/loki data/otel-logs
chmod