This guide walks through setting up OTEL telemetry from Claude Code to Prometheus + Grafana.
Claude Code --> OTLP/HTTP --> Prometheus --> Grafana
(metrics) (protobuf) (storage) (viz)
| { | |
| "description": "Monitor Claude Code usage, costs, tokens, and productivity metrics", | |
| "layout": [ | |
| { | |
| "h": 1, | |
| "i": "row-overview", | |
| "moved": false, | |
| "static": false, | |
| "w": 12, | |
| "x": 0, |
| { | |
| "apiVersion": "dashboard.grafana.app/v2beta1", | |
| "kind": "Dashboard", | |
| "metadata": { | |
| "name": "claude-code-metrics", | |
| "generation": 12, | |
| "creationTimestamp": "2025-12-10T13:33:56Z", | |
| "labels": {}, | |
| "annotations": {} | |
| }, |
| export FLAKE_BASE=$HOME/nixos/my-company | |
| export FLAKE_PATH=$FLAKE_BASE/${PWD##*/} | |
| watch_file $FLAKE_PATH/flake.nix | |
| watch_file .env | |
| use flake $FLAKE_PATH --impure | |
| export PYTHONPATH=$PWD |
| { | |
| inputs = { | |
| nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | |
| devenv.url = "github:cachix/devenv"; | |
| }; | |
| nixConfig = { | |
| extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; | |
| extra-substituters = "https://devenv.cachix.org"; | |
| }; |
| { config, lib, pkgs, helix, ... }: | |
| { | |
| imports = | |
| [ | |
| # Include the results of the hardware scan. | |
| ./hardware-configuration.nix | |
| ../../openrgb | |
| ]; |
| { config, pkgs, pkgs-stable, ... }: | |
| { | |
| imports = [ | |
| ./shell | |
| ./programs | |
| ]; | |
| home = { | |
| username = "mikelane"; |
| { | |
| description = "Mike's NixOS Flake"; | |
| nixConfig = { | |
| experimental-features = [ "nix-command" "flakes" ]; | |
| extra-substituters = [ | |
| # Nix community's cache server | |
| "https://nix-community.cachix.org" | |
| ]; | |
| extra-trusted-public-keys = [ |
| #!/usr/bin/env bash | |
| check_commands_available() { | |
| local missing_cmds=() | |
| local cmds=("sgpt" "pandoc") # Add any other required commands to this array | |
| for cmd in "${cmds[@]}"; do | |
| if ! command -v "$cmd" &> /dev/null; then | |
| missing_cmds+=("$cmd") | |
| fi |
| *.env | |
| # Created by .ignore support plugin (hsz.mobi) | |
| ### Diff template | |
| *.patch | |
| *.diff | |
| ### Windows template | |
| # Windows thumbnail cache files | |
| Thumbs.db |