Skip to content

Instantly share code, notes, and snippets.

@tedmax100
Created February 19, 2026 09:41
Show Gist options
  • Select an option

  • Save tedmax100/06f0b9830939eea0ee3c3ec8f1d478bc to your computer and use it in GitHub Desktop.

Select an option

Save tedmax100/06f0b9830939eea0ee3c3ec8f1d478bc to your computer and use it in GitHub Desktop.
claude-code grafana dashboard
{
"schemaVersion": 39,
"title": "Claude Code",
"uid": "claude-code",
"version": 11,
"tags": [
"claude-code",
"ai",
"telemetry"
],
"timezone": "browser",
"refresh": "30s",
"time": {
"from": "now-6h",
"to": "now"
},
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"templating": {
"list": []
},
"annotations": {
"list": []
},
"panels": [
{
"id": 1,
"type": "row",
"title": "Session Overview",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 2,
"type": "stat",
"title": "Total Sessions",
"gridPos": {
"x": 0,
"y": 1,
"w": 4,
"h": 3
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "blue",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "count(count by (session_id)(claude_code_active_time_seconds_total))",
"refId": "A",
"instant": true
}
]
},
{
"id": 3,
"type": "stat",
"title": "Total Cost (USD)",
"gridPos": {
"x": 4,
"y": 1,
"w": 4,
"h": 3
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 10
},
{
"color": "red",
"value": 50
}
]
},
"unit": "currencyUSD",
"decimals": 2
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(claude_code_cost_usage_USD_total[$__range]))",
"refId": "A",
"instant": true
}
]
},
{
"id": 4,
"type": "stat",
"title": "Total Tokens",
"gridPos": {
"x": 8,
"y": 1,
"w": 4,
"h": 3
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "purple",
"value": null
}
]
},
"unit": "short",
"decimals": 0
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(claude_code_token_usage_tokens_total[$__range]))",
"refId": "A",
"instant": true
}
]
},
{
"id": 5,
"type": "stat",
"title": "Tool Edits (Accepted)",
"gridPos": {
"x": 12,
"y": 1,
"w": 4,
"h": 3
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "orange",
"value": null
}
]
},
"unit": "short",
"decimals": 0
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(claude_code_code_edit_tool_decision_total{decision=\"accept\"}[$__range]))",
"refId": "A",
"instant": true
}
]
},
{
"id": 6,
"type": "stat",
"title": "Lines of Code Changed",
"gridPos": {
"x": 16,
"y": 1,
"w": 4,
"h": 3
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "teal",
"value": null
}
]
},
"unit": "short",
"decimals": 0
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(claude_code_lines_of_code_count_total[$__range]))",
"refId": "A",
"instant": true
}
]
},
{
"id": 7,
"type": "stat",
"title": "Active Time (h)",
"gridPos": {
"x": 20,
"y": 1,
"w": 4,
"h": 3
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "h",
"decimals": 1
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(claude_code_active_time_seconds_total[$__range])) / 3600",
"refId": "A",
"instant": true
}
]
},
{
"id": 8,
"type": "row",
"title": "Cost & Token Usage",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 4,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 9,
"type": "timeseries",
"title": "Cost Rate by Model",
"gridPos": {
"x": 0,
"y": 5,
"w": 12,
"h": 8
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"legend": {
"calcs": [
"sum"
],
"displayMode": "table",
"placement": "bottom"
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"gradientMode": "none"
},
"unit": "currencyUSD/s"
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (model)(rate(claude_code_cost_usage_USD_total[$__rate_interval]))",
"refId": "A",
"legendFormat": "{{model}}"
}
]
},
{
"id": 10,
"type": "timeseries",
"title": "Token Rate by Type",
"gridPos": {
"x": 12,
"y": 5,
"w": 12,
"h": 8
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"legend": {
"calcs": [
"sum"
],
"displayMode": "table",
"placement": "bottom"
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10
},
"unit": "short"
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (type)(rate(claude_code_token_usage_tokens_total[$__rate_interval]))",
"refId": "A",
"legendFormat": "{{type}}"
}
]
},
{
"id": 36,
"type": "timeseries",
"title": "Cost per 5 Minutes",
"description": "Spend accumulated in each 5-minute window, broken down by model \u2014 shows exactly when active usage occurs",
"gridPos": {
"x": 0,
"y": 13,
"w": 24,
"h": 6
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"legend": {
"calcs": [
"sum",
"max"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 0,
"fillOpacity": 80,
"gradientMode": "none",
"drawStyle": "bars",
"barAlignment": 0
},
"unit": "currencyUSD",
"decimals": 4
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (model)(increase(claude_code_cost_usage_USD_total[5m]))",
"refId": "A",
"legendFormat": "{{model}}"
}
]
},
{
"id": 11,
"type": "piechart",
"title": "Token Distribution",
"gridPos": {
"x": 0,
"y": 19,
"w": 8,
"h": 8
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"pieType": "donut",
"displayLabels": [
"name",
"percent"
],
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"sum"
]
},
"tooltip": {
"mode": "single"
}
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "short"
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (type)(increase(claude_code_token_usage_tokens_total[$__range]))",
"refId": "A",
"legendFormat": "{{type}}",
"instant": true
}
]
},
{
"id": 12,
"type": "piechart",
"title": "Cost by Model",
"gridPos": {
"x": 8,
"y": 19,
"w": 8,
"h": 8
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"pieType": "donut",
"displayLabels": [
"name",
"percent"
],
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"sum"
]
},
"tooltip": {
"mode": "single"
}
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "currencyUSD"
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (model)(increase(claude_code_cost_usage_USD_total[$__range]))",
"refId": "A",
"legendFormat": "{{model}}",
"instant": true
}
]
},
{
"id": 13,
"type": "stat",
"title": "Cache Hit Rate",
"description": "Percentage of tokens served from cache (cacheRead / total tokens)",
"gridPos": {
"x": 16,
"y": 19,
"w": 8,
"h": 8
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"textMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "yellow",
"value": 20
},
{
"color": "green",
"value": 50
}
]
},
"unit": "percent",
"decimals": 1,
"min": 0,
"max": 100
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * sum(increase(claude_code_token_usage_tokens_total{type=\"cacheRead\"}[$__range])) / sum(increase(claude_code_token_usage_tokens_total[$__range]))",
"refId": "A"
}
]
},
{
"id": 19,
"type": "row",
"title": "Logs & Events",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 44,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 20,
"type": "logs",
"title": "Tool Failures",
"gridPos": {
"x": 0,
"y": 45,
"w": 24,
"h": 6
},
"datasource": {
"type": "loki",
"uid": "loki"
},
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": true,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true,
"displayedFields": [
"tool_name",
"success",
"duration_ms",
"error"
]
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=\"claude-code\"} | event_name=`tool_result` | success=`false`",
"refId": "A"
}
]
},
{
"id": 21,
"type": "logs",
"title": "API Requests",
"gridPos": {
"x": 0,
"y": 51,
"w": 24,
"h": 6
},
"datasource": {
"type": "loki",
"uid": "loki"
},
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true,
"displayedFields": [
"model",
"cost_usd",
"duration_ms",
"input_tokens",
"output_tokens",
"cache_read_tokens"
]
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=\"claude-code\"} | event_name=`api_request`",
"refId": "A"
}
]
},
{
"id": 22,
"type": "logs",
"title": "Tool Executions",
"gridPos": {
"x": 0,
"y": 57,
"w": 24,
"h": 6
},
"datasource": {
"type": "loki",
"uid": "loki"
},
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true,
"displayedFields": [
"tool_name",
"success",
"duration_ms",
"tool_result_size_bytes"
]
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=\"claude-code\"} | event_name=`tool_result`",
"refId": "A"
}
]
},
{
"id": 23,
"type": "logs",
"title": "Permission Decisions",
"gridPos": {
"x": 0,
"y": 63,
"w": 24,
"h": 6
},
"datasource": {
"type": "loki",
"uid": "loki"
},
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true,
"displayedFields": [
"tool_name",
"decision",
"source"
]
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=\"claude-code\"} | event_name=`tool_decision`",
"refId": "A"
}
]
},
{
"id": 24,
"type": "logs",
"title": "User Prompts",
"gridPos": {
"x": 0,
"y": 69,
"w": 24,
"h": 6
},
"datasource": {
"type": "loki",
"uid": "loki"
},
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true,
"displayedFields": [
"prompt_length"
]
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=\"claude-code\"} | event_name=`user_prompt`",
"refId": "A"
}
]
},
{
"id": 28,
"type": "row",
"title": "Top 10 Tools",
"collapsed": false,
"gridPos": {
"x": 0,
"y": 27,
"w": 24,
"h": 1
},
"panels": []
},
{
"id": 29,
"type": "barchart",
"title": "Top 10 Tools by Execution Count",
"description": "Most frequently called tools across all executions in the selected time range",
"gridPos": {
"x": 0,
"y": 28,
"w": 12,
"h": 8
},
"datasource": {
"type": "loki",
"uid": "loki"
},
"options": {
"barWidth": 0.7,
"groupWidth": 0.7,
"orientation": "horizontal",
"stacking": "none",
"legend": {
"calcs": [
"sum"
],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "desc"
}
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"fillOpacity": 80
},
"unit": "short"
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "topk(10, sum by (tool_name)(count_over_time({service_name=\"claude-code\"} | event_name=`tool_result` [$__range])))",
"refId": "A",
"legendFormat": "{{tool_name}}",
"instant": true,
"queryType": "instant"
}
]
},
{
"id": 30,
"type": "barchart",
"title": "Top 10 Tools by Avg Execution Time (ms)",
"description": "Average execution time per tool \u2014 identify performance bottlenecks",
"gridPos": {
"x": 12,
"y": 28,
"w": 12,
"h": 8
},
"datasource": {
"type": "loki",
"uid": "loki"
},
"options": {
"barWidth": 0.7,
"groupWidth": 0.7,
"orientation": "horizontal",
"stacking": "none",
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "desc"
}
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"fillOpacity": 80
},
"unit": "ms"
},
"overrides": []
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "topk(10, avg_over_time({service_name=\"claude-code\"} | event_name=`tool_result` | unwrap duration_ms [$__range]) by (tool_name))",
"refId": "A",
"legendFormat": "{{tool_name}}",
"instant": true,
"queryType": "instant"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment