Claude Monitor Track token usage, costs, and tool calls for Claude Code sessions

hackernews | | {'이벤트': '📰', '머신러닝/연구': '📰', '하드웨어/반도체': '📰', '취약점/보안': '📰', '기타 AI': '📰', 'AI 딜': '📰', 'AI 모델': '📰', 'AI 서비스': '📰', 'discount': '📰', 'news': '📰', 'review': '📰', 'tip': '📰'} news
#claude #claude code #모니터링 #비용 관리 #토큰 추적

요약

클로드 모니터는 클로드 코드 세션에서 발생하는 토큰 사용량과 비용, 그리고 툴 호출 내역을 추적하는 기능을 제공합니다. 이를 통해 사용자는 자신의 세션 활동을 효율적으로 모니터링하고 관리할 수 있습니다.

왜 중요한가

개발자 관점

클로드 코드 세션의 리소스 사용량을 실시간으로 시각화하여, 토큰 과다 사용을 방지하고 API 호출 최적화를 통해 개발 효율성을 높일 수 있는 필수적인 디버깅 도구입니다.

연구자 관점

LLM이 코드 생성 및 실행 과정에서 도구(Tool)를 어떻게 활용하는지에 대한 상호작용 데이터를 정량적으로 수집함으로써, 에이전트의 행동 패턴과 추론 과정을 분석하는 데 중요한 로그를 제공합니다.

비즈니스 관점

AI 도입 시 발생하는 불확실한 운영 비용을 투명하게 공개하여 예산 관리를 수월하게 하고, 툴 사용 횟수 분석을 통해 구체적인 생산성 지표(ROI)를 산출하는 데 기여합니다.

본문

A comprehensive monitoring and visualization tool for Claude Code sessions. Track token usage, costs, tool calls, and session activity through a real-time web dashboard. - Real-time monitoring -- WebSocket-powered live view of active Claude Code sessions - Session tracking -- Automatic capture of session metadata, messages, and tool calls via Claude Code hooks - Log file watching -- Monitors ~/.claude/projects/ for new and modified JSONL log files - Historical import -- Bulk import of existing Claude Code session logs - Cost estimation -- Per-session cost calculation based on configurable model pricing - Full-text search -- Search across all message content using SQLite FTS5 - Token analytics -- Input, output, cache read, and cache write token breakdowns - Tool usage stats -- Track which tools are used most and their success rates - Project breakdown -- Per-project session and cost summaries - Export -- Export sessions as JSON, CSV, or HTML - Web dashboard -- Single-page application with dashboard, sessions, live, tools, projects, cost, and settings pages Build from source: make build Or install to /usr/local/bin : make install # 1. Install hooks and initialize the database claude-monitor install # 2. Import existing Claude Code session logs claude-monitor import # 3. Start the web UI claude-monitor serve # Visit http://localhost:3000 Install Claude Code hooks and initialize the database. claude-monitor install [--force] --force -- Overwrite existing hook configuration Remove hooks and optionally delete all data. claude-monitor uninstall [--delete-data] --delete-data -- Also remove the database and configuration files Start the monitoring daemon and web UI. claude-monitor serve [--port PORT] [--host HOST] [--no-browser] --port -- HTTP port (default: from config, typically 3000)--host -- HTTP host (default: from config, typically 127.0.0.1)--no-browser -- Do not open the browser on start Import historical Claude Code session logs from JSONL files. claude-monitor import [--path PATH] --path -- Path to Claude Code projects directory (default:~/.claude/projects ) Export sessions as JSON, CSV, or HTML. claude-monitor export [--format FORMAT] [--output FILE] [--from DATE] [--to DATE] [--project NAME] --format -- Output format:json ,csv , orhtml (default:json )--output -- Output file path (default: stdout)--from -- Start date filter (RFC3339)--to -- End date filter (RFC3339)--project -- Filter by project name or path Manage configuration. claude-monitor config [--show] [--reset] --show -- Display current configuration--reset -- Reset configuration to defaults Show daemon status and database statistics. claude-monitor status Print version information. claude-monitor version Configuration is stored in ~/.claude-monitor/config.yaml . Key settings: server: port: 3000 host: "127.0.0.1" cost: models: opus: input: 15.0 # $/million tokens output: 75.0 cache_read: 1.5 cache_write: 18.75 sonnet: input: 3.0 output: 15.0 cache_read: 0.3 cache_write: 3.75 haiku: input: 0.25 output: 1.25 cache_read: 0.03 cache_write: 0.3 storage: database_path: "~/.claude-monitor/claude-monitor.db" retention_days: 0 # 0 = keep forever ui: theme: "auto" # auto, light, dark default_page: "dashboard" sessions_per_page: 50 - Hook receiver -- Listens on a Unix socket ( ~/.claude-monitor/monitor.sock ) for real-time hook events from Claude Code - Log watcher -- Uses fsnotify to detect changes to JSONL log files under ~/.claude/projects/ - Ingestion pipeline -- Batches, deduplicates, and writes events to SQLite with FTS5 - REST API -- JSON endpoints for sessions, messages, tool calls, stats, search, and config - WebSocket hub -- Broadcasts real-time events to connected dashboard clients - Web UI -- Embedded static SPA served by the Go binary | Endpoint | Method | Description | |---|---|---| /api/sessions | GET | List sessions (supports project , from , to , limit , offset ) | /api/sessions/{id} | GET | Session detail with messages, tool calls, and subagents | /api/messages | GET | List messages (supports session_id , type , limit , offset ) | /api/tool-calls | GET | List tool calls (supports session_id , tool_name , limit , offset ) | /api/subagents | GET | List subagents (supports session_id , limit , offset ) | /api/stats | GET | Dashboard aggregate statistics | /api/stats/daily | GET | Daily activity for charts (supports days ) | /api/stats/tools | GET | Tool usage breakdown | /api/stats/models | GET | Model usage breakdown | /api/stats/projects | GET | Project activity breakdown | /api/search | GET | Full-text search on messages (requires q ) | /api/config | GET/POST | Get or update configuration | /ws | WebSocket | Real-time event stream | # Run tests make test # Build make build # Run make run Apache License 2.0 -- see LICENSE for details.

관련 저널 읽기

전체 보기 →