一个完全本地的指标管道,用于 Claude Code 和 OpenAI Codex CLI,通过 OpenTelemetry Collector 将 OTLP 遥测数据导入 Prometheus 和 Grafana,实现统一监控。

Stars

6

7 天增长

暂无数据

Fork 数

0

开放 Issue

0

开源协议

MIT

最近更新

2026-07-28

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它将两个主要 AI 编码助手工具的代币、成本和生产力指标统一到一个自托管堆栈中,提供自动化的 Grafana 仪表盘和严格的隐私过滤。

适合谁使用

  • 使用 Claude Code 和/或 Codex CLI 的开发者
  • 希望本地化观察 AI 编码工具使用情况的工程团队
  • 负责 AI 助手成本与资源追踪的平台工程师
  • 倾向于不将指标发送到外部服务的安全意识用户

典型使用场景

  • 在单一仪表盘中跟踪 Claude Code 和 Codex CLI 的代币消耗和预估成本
  • 比较提供商发出的成本估算与标价等价成本
  • 监控命名代理活动及其在代币使用中的占比
  • 衡量编码生产力指标,如提交次数和代码行变更

项目优势

  • 完全本地运行,默认将已发布端口绑定到 127.0.0.1,数据保留在本地机器上
  • 自动配置 Grafana 仪表盘,包含概览、代币使用、成本、代理和会话五个区域
  • 隐私优先设计:收集器在数据到达 Prometheus 之前会剥离会话 ID、账户 ID 等身份信息
  • 支持并发安全,通过增量压缩和锁文件序列化实现钩子和堆栈脚本的原子操作

使用前须知

  • 指标是尽力而为的观测,不保证财务准确性——不支持恰好一次传递或崩溃安全的确认批次
  • 需要特定客户端版本(Claude Code ≥2.1.214,Codex CLI ≥0.145.0),仅支持 macOS 或 Ubuntu
  • Prometheus 和收集器无内置认证,Grafana 密码仅保护 Grafana 自身

README 快速开始

cc-metrics

Local metrics pipeline for Claude Code and OpenAI Codex CLI:

Claude Code ─┐
             ├─ OTLP ─> OpenTelemetry Collector ─> Prometheus ─> Grafana
Codex CLI ───┘

Runs entirely on your machine. Published ports bind to 127.0.0.1 by default. Client authentication stays in Claude Code or Codex; this stack needs no provider API key.

Dashboard

One Grafana dashboard, "Token & Usage Monitor", provisioned automatically. Five rows:

rowwhat it answers
Overviewsession starts, tokens, estimated cost, Codex threads, active time, cache hit rate
Token Usagetokens over time, split by type, model, and Claude effort level
Cost Analysisestimated cost over time and by model, across both vendors
Agentstokens and estimated cost for Claude traffic carrying a named agent
Sessions & Productivitycommits, pull requests, lines changed, edit decisions

Cost split by model across both vendors is the reason this exists rather than either vendor's own view. Claude figures are the provider's own estimates; Codex figures are list-price estimates computed here — see Cost meaning for what that difference implies.

Overview headline tiles:

Token usage over the selected range, split by token type:

The Codex side of the cost split, priced from the list-price rules:

Named-agent attribution — the share of Claude tokens carrying an agent name, and its split by agent type:

Every panel is empty until a client sends data. Setup steps 3 and 4 do that.

Features

  • Claude Code and Codex token views under one ai_* metric namespace.
  • Provider-emitted Claude cost estimates.
  • Standard OpenAI API list-price estimates for selected Codex models.
  • Configurable host ports, environment label, retention, and image references.
  • Optional, forward-looking Codex commit counter.
  • Prometheus rule, dashboard contract, hook, pricing, and hygiene tests.

Requirements

ComponentSupported requirement
HostmacOS or Ubuntu only
ContainersDocker with docker compose
Claude Code2.1.214 or newer for corrected streaming token/cost accounting
Codex CLI0.145.0 or newer for GPT-5.6 cache-write telemetry
Python3.10 or newer for hook installation, pricing maintenance, and tests
GitNeeded for cloning and the optional commit metric
Password g

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

lopopolo
精选
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI 与机器学习AI 智能体
2,390
slvDev
精选
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI 与机器学习大语言模型
1,960
littledivy
精选
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI 与机器学习
1,482