Claude Code Metrics

Comprehensive monitoring dashboard for Claude Code CLI usage. Track sessions, tokens, costs, commits, pull requests, lines of code, and developer productivity metrics. Compatible with Prometheus, VictoriaMetrics, Mimir, and Thanos. Metrics required: - claude_code_session_count_total - claude_code_token_usage_tokens_total - claude_code_cost_usage_USD_total - claude_code_active_time_seconds_total - claude_code_lines_of_code_count_total - claude_code_commit_count_total - claude_code_pull_request_count_total - claude_code_code_edit_tool_decision_total For metric collection setup, see: https://github.com/anthropics/claude-code

Claude Code Metrics Dashboard

A comprehensive Grafana dashboard for monitoring Claude Code CLI usage, costs, and developer productivity metrics.

Dashboard Preview

Dashboard Overview

Features

  • Usage Overview: Sessions, users, tokens, and costs at a glance
  • Cost Tracking: Track spending by model, user, and repository
  • Token Analytics: Monitor token usage by type (input, output, cache)
  • Productivity Metrics: Lines of code, commits, and pull requests
  • Leaderboards: Top users and repositories by cost/tokens
  • Multi-dimensional Filtering: Filter by organization, user, model, and repository

Requirements

Grafana Version

  • Grafana 10.0.0 or higher

Datasource

  • Any Prometheus-compatible datasource:
    • Prometheus
    • VictoriaMetrics
    • Mimir
    • Thanos
    • Cortex

Required Metrics

Your Claude Code telemetry must expose these metrics:

MetricTypeLabelsDescription
claude_code_session_count_totalCounteruser_email, organization_id, marlin_git_repo, terminal_typeNumber of CLI sessions
claude_code_token_usage_tokens_totalCounteruser_email, organization_id, model, type, marlin_git_repoToken consumption
claude_code_cost_usage_USD_totalCounteruser_email, organization_id, model, marlin_git_repoEstimated cost in USD
claude_code_active_time_seconds_totalCounteruser_email, organization_id, type, marlin_git_repoActive time (cli/user)
claude_code_lines_of_code_count_totalCounteruser_email, organization_id, type, marlin_git_repoLines added/removed
claude_code_commit_count_totalCounteruser_email, organization_id, marlin_git_repoGit commits created
claude_code_pull_request_count_totalCounteruser_email, organization_id, marlin_git_repoPRs created
claude_code_code_edit_tool_decision_totalCounteruser_email, organization_id, decision, language, marlin_git_repoTool accept/reject

Label Reference

LabelDescriptionExample Values
user_emailUser's email addressuser@example.com
organization_idOrganization identifierorg-123
modelClaude model usedclaude-opus-4-6, claude-haiku-4-5-20251001
type (tokens)Token typeinput, output, cacheRead, cacheCreation
type (time)Time typecli, user
type (loc)Change typeadded, removed
decisionUser decisionaccept, reject
languageProgramming languageGo, Python, JavaScript
terminal_typeTerminal/IDE typevscode, iTerm.app
marlin_git_repoGit repositorygithub.com/org/repo, no-remote

Installation

Option 1: Import from Grafana.com

  1. Go to your Grafana instance
  2. Navigate to Dashboards > Import
  3. Enter the dashboard ID: XXXXX (will be assigned after publishing)
  4. Select your Prometheus-compatible datasource
  5. Click Import

Option 2: Import JSON

  1. Download cc_metrics.json from this repository
  2. Go to your Grafana instance
  3. Navigate to Dashboards > Import
  4. Click Upload JSON file and select the downloaded file
  5. Select your Prometheus-compatible datasource
  6. Click Import

Option 3: Using Grafana Provisioning

Add the dashboard to your provisioning configuration:

# /etc/grafana/provisioning/dashboards/claude-code.yaml
apiVersion: 1
providers:
  - name: 'Claude Code'
    orgId: 1
    folder: 'Claude Code'
    type: file
    disableDeletion: false
    editable: true
    options:
      path: /var/lib/grafana/dashboards/claude-code

Then place cc_metrics.json in /var/lib/grafana/dashboards/claude-code/.

Configuration

Variables

The dashboard includes the following template variables:

VariableDescriptionDefault
DS_PROMETHEUSPrometheus-compatible datasource(select on import)
organizationFilter by organization IDAll
userFilter by user emailAll
modelFilter by Claude modelAll
repoFilter by git repositoryAll

Customization

  • Time Range: Default is last 7 days, adjustable via time picker
  • Refresh Interval: Default 30 seconds, adjustable via refresh dropdown
  • Thresholds: Cost thresholds can be customized in panel settings

Dashboard Sections

1. Overview Row

Quick stats showing sessions, users, cost, tokens, commits, PRs, and lines of code.

2. Cost & Tokens

  • Cost over time (hourly rate)
  • Cost breakdown by model
  • Token usage by type (stacked)
  • Token usage by model

3. Activity & Productivity

  • Sessions over time
  • Active time (CLI vs user interaction)
  • Lines of code (added vs removed)
  • Tool decisions (accept vs reject)

4. Leaderboards

  • Top users by cost
  • Top users by tokens
  • Top repositories by cost
  • Cost distribution by model (pie chart)
  • Tool usage by language (pie chart)
  • Sessions by terminal type (pie chart)

Metrics Collection Setup

To collect these metrics, you need to configure Claude Code to send telemetry to your metrics backend. See the Claude Code documentation for setup instructions.

Example: Using Marlin LLM Gateway

If you're using Marlin as your LLM gateway, metrics are automatically collected and exposed in Prometheus format.

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

License

This dashboard is released under the MIT License.

Changelog

v1.0.0 (2026-03-11)

  • Initial public release
  • Overview, Cost & Tokens, Activity & Productivity, Leaderboards sections
  • Support for Prometheus-compatible datasources
  • Template variables for filtering

Support

Revisions
RevisionDescriptionCreated

Get this dashboard

Import the dashboard template

or

Download JSON

Datasource
Dependencies