Commit 9b2fc27
Add token usage and model tracking to Claude billing (#7729)
## Summary
- Adds token tracking fields to `misc.claude_code_usage` schema:
- `input_tokens`, `output_tokens`
- `cache_read_input_tokens`, `cache_creation_input_tokens`
- `model`
- Updates `upload-claude-usage` action to extract these fields from
Claude output
- Updates S3 replicator lambda to handle new fields
- Creates v2 Grafana dashboard with token metrics
## Dashboard v2
https://pytorchci.grafana.net/public-dashboards/83058a8d65d44a099eb8d9ac2916f411
New metrics:
- Total input/output tokens
- Cache hit rate
- Cost by model breakdown
- Token usage by workflow
- Daily cache performance
## Test plan
- [ ] Deploy schema changes (ALTER TABLE to add columns)
- [ ] Deploy lambda changes
- [ ] Verify new data flows with token fields populated
- [ ] Verify v2 dashboard shows token metrics
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <[email protected]>1 parent a08e3d5 commit 9b2fc27
File tree
3 files changed
+22
-2
lines changed- .github/actions/upload-claude-usage
- aws/lambda/clickhouse-replicator-s3
- clickhouse_db_schema/misc.claude_code_usage
3 files changed
+22
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| |||
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
57 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
58 | 68 | | |
59 | 69 | | |
60 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
680 | 680 | | |
681 | 681 | | |
682 | 682 | | |
683 | | - | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
684 | 689 | | |
685 | 690 | | |
686 | 691 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
0 commit comments