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

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:
| Metric | Type | Labels | Description |
|---|---|---|---|
claude_code_session_count_total | Counter | user_email, organization_id, marlin_git_repo, terminal_type | Number of CLI sessions |
claude_code_token_usage_tokens_total | Counter | user_email, organization_id, model, type, marlin_git_repo | Token consumption |
claude_code_cost_usage_USD_total | Counter | user_email, organization_id, model, marlin_git_repo | Estimated cost in USD |
claude_code_active_time_seconds_total | Counter | user_email, organization_id, type, marlin_git_repo | Active time (cli/user) |
claude_code_lines_of_code_count_total | Counter | user_email, organization_id, type, marlin_git_repo | Lines added/removed |
claude_code_commit_count_total | Counter | user_email, organization_id, marlin_git_repo | Git commits created |
claude_code_pull_request_count_total | Counter | user_email, organization_id, marlin_git_repo | PRs created |
claude_code_code_edit_tool_decision_total | Counter | user_email, organization_id, decision, language, marlin_git_repo | Tool accept/reject |
Label Reference
| Label | Description | Example Values |
|---|---|---|
user_email | User's email address | user@example.com |
organization_id | Organization identifier | org-123 |
model | Claude model used | claude-opus-4-6, claude-haiku-4-5-20251001 |
type (tokens) | Token type | input, output, cacheRead, cacheCreation |
type (time) | Time type | cli, user |
type (loc) | Change type | added, removed |
decision | User decision | accept, reject |
language | Programming language | Go, Python, JavaScript |
terminal_type | Terminal/IDE type | vscode, iTerm.app |
marlin_git_repo | Git repository | github.com/org/repo, no-remote |
Installation
Option 1: Import from Grafana.com
- Go to your Grafana instance
- Navigate to Dashboards > Import
- Enter the dashboard ID:
XXXXX(will be assigned after publishing) - Select your Prometheus-compatible datasource
- Click Import
Option 2: Import JSON
- Download
cc_metrics.jsonfrom this repository - Go to your Grafana instance
- Navigate to Dashboards > Import
- Click Upload JSON file and select the downloaded file
- Select your Prometheus-compatible datasource
- 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:
| Variable | Description | Default |
|---|---|---|
DS_PROMETHEUS | Prometheus-compatible datasource | (select on import) |
organization | Filter by organization ID | All |
user | Filter by user email | All |
model | Filter by Claude model | All |
repo | Filter by git repository | All |
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
- Issues: GitHub Issues
- Documentation: Claude Code Docs
Data source config
Collector config:
Upload an updated version of an exported dashboard.json file from Grafana
| Revision | Description | Created | |
|---|---|---|---|
| Download |