2 pointsby kisamoto6 hours ago2 comments
  • kisamoto6 hours ago
    Claude Code supports using OpenTelemetry to gather some metrics including token usage, cost, user prompts and tool calls (unfortunately no system prompts).

    This is possible without custom certificates, MITM or proxies. However you do need something to collect, store and visualise the OTEL data.

    I use Grafana Alloy (running in Docker) and Grafana Cloud for this but you could use any OTEL provider including SigNoz.

    Leave it running, track your usage and when you hit limits look back to understand how many tokens that actually was.

    • kisamoto4 hours ago
      As someone on Reddit pointed out, now that it's in the Grafana stack you can also use standard alert management & notification tools to send updates on usage and alerts for abnormal spikes.
  • laplaque4 hours ago
    Nice — Prometheus/Grafana is the right call for token spend visibility. The harder part I've found is seeing what's actually in the traffic, not just how much. I ended up building an open-source MITM proxy for that — Prometheus metrics endpoint is on the roadmap but not there yet.
    • kisamoto4 hours ago
      You can get user prompts and tool calls in the logs (but not system prompts) although you do have to set a couple of extra environment variables.

      It's under the `prompt` and `tool_parameter` fields in the logs.

          {service_name=~"claude-code"} | prompt != ""  | line_format `prompt={{.prompt}}`