Real-time telemetry monitoring and analytics for Claude Code sessions
Track token usage, monitor costs, and analyze Claude Code performance with beautiful dashboards and comprehensive analytics.
๐ Quick Start โข โจ Features โข ๐ Dashboard โข ๐ง Configuration โข ๐ Analytics
Claude Code Monitor is a comprehensive OpenTelemetry-based monitoring solution specifically designed to capture, store, and visualize Claude Code token usage and cost data in real-time. Whether you're a developer tracking API costs or a team analyzing AI tool usage patterns, this tool provides the insights you need.
- ๐ฐ Cost Transparency: Track exact token costs by model and session
- ๐ Usage Insights: Understand your Claude Code usage patterns over time
- ๐ Real-time Monitoring: See live token consumption as you work
- ๐ Rich Analytics: Comprehensive reports and trend analysis
- ๐ Easy Integration: Seamless OpenTelemetry integration with minimal setup
- ๐จ Beautiful Dashboards: Interactive web interface with charts and visualizations
- ๐ก Real-time Telemetry: Receives Claude Code metrics via OTLP protocol
- ๐ Token Analytics: Track input, output, cache read/creation tokens
- ๐ฐ Cost Tracking: Monitor spending across different AI models
- ๐ Interactive Dashboard: Beautiful web interface with real-time charts
- ๐ Prometheus Export: Industry-standard metrics for external monitoring
- ๐ Usage Reports: Daily, weekly, and historical analysis
- ๐ Session Tracking: Monitor individual Claude Code sessions
- Real-time token distribution charts
- Per-model cost breakdown
- 30-day historical trends
- Auto-refresh every 30 seconds
- Responsive design for all devices
- Daily usage summaries
- Weekly trend analysis
- Cost optimization insights
- Token efficiency metrics
- Session duration tracking
npm install./setup-claude-telemetry.sh
source ~/.bashrc # or ~/.zshrc for zsh users# Start the OTLP receiver
npm run receiver
# In another terminal, start the web dashboard
npm run webUse Claude Code normally - tokens will be automatically tracked! ๐
Access your monitoring dashboard at:
- Web Interface: http://localhost:3000
- Prometheus Metrics: http://localhost:9464/metrics
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Claude Code Usage Dashboard โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Today's Stats Token Distribution โ
โ โข 1,234 Input โโโโโโโโโโโโ 45% โ
โ โข 2,567 Output โโโโโโโโโโโโ 55% โ
โ โข 15,432 Cache Read โโโโโโโโโโโโ 89% โ
โ โข 1,098 Cache Create โโโโโโโโโโโโ 11% โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ฐ Cost Breakdown ๐ 30-Day Trend โ
โ โข Model A: $12.34 โฒโฒโฒโฒโฒโฒโฒโฒโฒโฒโฒ โ
โ โข Model B: $5.67 โฒโฒโฒโฒโฒโฒโฒโฒโฒโฒโฒ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
If you prefer manual configuration:
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json| Variable | Default | Description |
|---|---|---|
CLAUDE_CODE_ENABLE_TELEMETRY |
1 |
Enable Claude Code telemetry |
OTEL_EXPORTER_OTLP_ENDPOINT |
http://localhost:4318 |
OTLP endpoint URL |
OTEL_EXPORTER_OTLP_PROTOCOL |
http/json |
Protocol format |
OTEL_EXPORTER_PROMETHEUS_PORT |
9464 |
Prometheus metrics port |
npm run receiver # ๐ฏ Start OTLP receiver for telemetry
npm run web # ๐ Launch web dashboard
npm run monitor # ๐ Start Prometheus metrics exportnpm run report # ๐ Generate comprehensive usage report
npm run report daily # ๐
Today's detailed usage
npm run report weekly # ๐ Weekly summary and trendsnpm run test-data # ๐งช Generate sample test data
npm run test-session # ๐ฌ Simulate single session
npm run test-history # ๐ Generate historical dataGet detailed insights into your Claude Code usage:
$ npm run report daily
๐ Claude Code Usage Report - 2024-01-15
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Token Usage:
โข Input Tokens: 1,234 (12.3%)
โข Output Tokens: 2,567 (25.7%)
โข Cache Read: 5,432 (54.3%)
โข Cache Creation: 768 (7.7%)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โข Total Tokens: 10,001
๐ฐ Cost Breakdown:
โข claude-3-sonnet-20241022: $12.34
โข claude-3-haiku-20240307: $3.45
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โข Total Cost: $15.79
๐ Performance:
โข Sessions: 47
โข Avg Tokens/Session: 213
โข Peak Hour: 14:00-15:00Monitor your metrics with industry-standard tools:
- Grafana Dashboards: Import pre-built dashboards
- Alert Rules: Set up cost and usage alerts
- Historical Data: Long-term trend analysis
ccmonitor/
โโโ daily-usage.json # ๐พ Primary data store
โโโ logs/ # ๐ Application logs
โโโ config/ # โ๏ธ Configuration files
Data is stored in JSON format with incremental daily aggregation:
{
"2024-01-15": {
"inputTokens": 1234,
"outputTokens": 2567,
"cacheReadTokens": 5432,
"cacheCreationTokens": 768,
"totalTokens": 10001,
"sessions": 47,
"modelCosts": {
"claude-3-sonnet-20241022": 12.34
}
}
}Monitor Claude Code usage on remote servers:
# Create SSH tunnel
ssh -L 3000:localhost:3000 -L 9464:localhost:9464 user@server
# Access dashboards locally
open http://localhost:3000 # Web dashboard
open http://localhost:9464 # Prometheus metricsDeploy with Docker for production environments:
# Build and run
docker build -t claude-monitor .
docker run -p 3000:3000 -p 4318:4318 -p 9464:9464 claude-monitorWe welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/yourusername/claude-code-monitor.git
cd claude-code-monitor
npm install
npm run devThis project is licensed under the MIT License - see the LICENSE file for details.
- ๐ Documentation: Check our Wiki
- ๐ Bug Reports: Create an Issue
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Email: Support Email
- OpenTelemetry for the telemetry framework
- Claude Code for the amazing AI coding assistant
- Prometheus for metrics collection
- Express.js for the web framework
Made with โค๏ธ for the Claude Code community
โญ Star us on GitHub โข ๐ Report Bug โข ๐ก Request Feature