Skip to content

Instantly share code, notes, and snippets.

@mprokopov
Last active March 9, 2026 10:45
Show Gist options
  • Select an option

  • Save mprokopov/75b40f0f0420e93255f3502ab0ab67a2 to your computer and use it in GitHub Desktop.

Select an option

Save mprokopov/75b40f0f0420e93255f3502ab0ab67a2 to your computer and use it in GitHub Desktop.
Grafana dashboard for pi-otel-telemetry extension (pi coding agent OTEL traces & metrics)
{
"__elements": {},
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "11.0.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "datasource",
"id": "tempo",
"name": "Tempo",
"version": "1.0.0"
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "barchart",
"name": "Bar chart",
"version": ""
},
{
"type": "panel",
"id": "piechart",
"name": "Pie chart",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
},
{
"type": "panel",
"id": "histogram",
"name": "Histogram",
"version": ""
}
],
"id": null,
"uid": "pi-otel-telemetry",
"title": "Pi Coding Agent \u2014 OTEL Telemetry",
"description": "OpenTelemetry traces & metrics for pi coding agent sessions",
"tags": [
"pi",
"otel",
"llm",
"coding-agent"
],
"timezone": "browser",
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"links": [],
"panels": [
{
"type": "row",
"title": "Overview",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"collapsed": false,
"panels": []
},
{
"type": "stat",
"title": "Total Prompts",
"description": "Total user prompts sent to the agent",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 4,
"w": 4,
"x": 0,
"y": 1
},
"fieldConfig": {
"defaults": {
"thresholds": {
"steps": [
{
"color": "blue",
"value": null
},
{
"color": "green",
"value": 10
},
{
"color": "yellow",
"value": 100
}
]
},
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
]
},
"colorMode": "background",
"graphMode": "none",
"textMode": "auto"
},
"targets": [
{
"expr": "sum(pi_prompts{job=\"pi-coding-agent\"})",
"legendFormat": "Prompts",
"refId": "A"
}
]
},
{
"type": "stat",
"title": "Total Turns",
"description": "Total LLM turns (one turn = one LLM call + tool executions)",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 4,
"w": 4,
"x": 4,
"y": 1
},
"fieldConfig": {
"defaults": {
"thresholds": {
"steps": [
{
"color": "blue",
"value": null
},
{
"color": "green",
"value": 50
},
{
"color": "yellow",
"value": 500
}
]
},
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
]
},
"colorMode": "background",
"graphMode": "none",
"textMode": "auto"
},
"targets": [
{
"expr": "sum(pi_turns{job=\"pi-coding-agent\"})",
"legendFormat": "Turns",
"refId": "A"
}
]
},
{
"type": "stat",
"title": "Total Tool Calls",
"description": "Total tool invocations across all sessions",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 4,
"w": 4,
"x": 8,
"y": 1
},
"fieldConfig": {
"defaults": {
"thresholds": {
"steps": [
{
"color": "purple",
"value": null
},
{
"color": "green",
"value": 50
},
{
"color": "orange",
"value": 500
}
]
},
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
]
},
"colorMode": "background",
"graphMode": "none",
"textMode": "auto"
},
"targets": [
{
"expr": "sum(pi_tool_calls{job=\"pi-coding-agent\"})",
"legendFormat": "Tool Calls",
"refId": "A"
}
]
},
{
"type": "stat",
"title": "Tool Errors",
"description": "Total failed tool executions",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 4,
"w": 4,
"x": 12,
"y": 1
},
"fieldConfig": {
"defaults": {
"thresholds": {
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 1
},
{
"color": "red",
"value": 10
}
]
},
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
]
},
"colorMode": "background",
"graphMode": "none",
"textMode": "auto"
},
"targets": [
{
"expr": "sum(pi_tool_errors{job=\"pi-coding-agent\"}) or vector(0)",
"legendFormat": "Errors",
"refId": "A"
}
]
},
{
"type": "stat",
"title": "Input Tokens",
"description": "Total input tokens consumed",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 4,
"w": 4,
"x": 16,
"y": 1
},
"fieldConfig": {
"defaults": {
"thresholds": {
"steps": [
{
"color": "blue",
"value": null
},
{
"color": "yellow",
"value": 1000000
},
{
"color": "red",
"value": 10000000
}
]
},
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
]
},
"colorMode": "background",
"graphMode": "area",
"textMode": "auto"
},
"targets": [
{
"expr": "sum(pi_tokens_input{job=\"pi-coding-agent\"})",
"legendFormat": "Input",
"refId": "A"
}
]
},
{
"type": "stat",
"title": "Output Tokens",
"description": "Total output tokens produced",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 4,
"w": 4,
"x": 20,
"y": 1
},
"fieldConfig": {
"defaults": {
"thresholds": {
"steps": [
{
"color": "blue",
"value": null
},
{
"color": "yellow",
"value": 500000
},
{
"color": "red",
"value": 5000000
}
]
},
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
]
},
"colorMode": "background",
"graphMode": "area",
"textMode": "auto"
},
"targets": [
{
"expr": "sum(pi_tokens_output{job=\"pi-coding-agent\"})",
"legendFormat": "Output",
"refId": "A"
}
]
},
{
"type": "row",
"title": "Token Usage",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 5
},
"collapsed": false,
"panels": []
},
{
"type": "timeseries",
"title": "Token Consumption Rate",
"description": "Input and output tokens per minute",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 6
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 20,
"pointSize": 5,
"showPoints": "auto",
"spanNulls": true,
"stacking": {
"mode": "none"
}
},
"unit": "short"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Input"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "blue",
"mode": "fixed"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Output"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "orange",
"mode": "fixed"
}
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"expr": "sum(rate(pi_tokens_input{job=\"pi-coding-agent\"}[5m])) * 60",
"legendFormat": "Input",
"refId": "A"
},
{
"expr": "sum(rate(pi_tokens_output{job=\"pi-coding-agent\"}[5m])) * 60",
"legendFormat": "Output",
"refId": "B"
}
]
},
{
"type": "timeseries",
"title": "Tokens by Model",
"description": "Total token consumption broken down by model",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 6
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 15,
"stacking": {
"mode": "normal"
}
},
"unit": "short"
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"calcs": [
"sum"
]
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"expr": "sum by (llm_model) (rate(pi_tokens_input{job=\"pi-coding-agent\"}[5m]) + rate(pi_tokens_output{job=\"pi-coding-agent\"}[5m])) * 60",
"legendFormat": "{{llm_model}}",
"refId": "A"
}
]
},
{
"type": "row",
"title": "Tool Usage",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 14
},
"collapsed": false,
"panels": []
},
{
"type": "piechart",
"title": "Tool Call Distribution",
"description": "Breakdown of tool calls by tool name",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 8,
"x": 0,
"y": 15
},
"options": {
"legend": {
"displayMode": "table",
"placement": "right",
"values": [
"value",
"percent"
]
},
"pieType": "donut",
"tooltip": {
"mode": "single"
},
"reduceOptions": {
"calcs": [
"lastNotNull"
]
}
},
"targets": [
{
"expr": "sum by (tool_name) (pi_tool_calls{job=\"pi-coding-agent\"})",
"legendFormat": "{{tool_name}}",
"refId": "A"
}
]
},
{
"type": "timeseries",
"title": "Tool Calls Rate",
"description": "Tool invocations per minute by tool name",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 8,
"x": 8,
"y": 15
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "bars",
"fillOpacity": 80,
"stacking": {
"mode": "normal"
}
},
"unit": "short"
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"expr": "sum by (tool_name) (rate(pi_tool_calls{job=\"pi-coding-agent\"}[5m])) * 60",
"legendFormat": "{{tool_name}}",
"refId": "A"
}
]
},
{
"type": "histogram",
"title": "Tool Execution Duration",
"description": "Distribution of tool execution times",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 8,
"x": 16,
"y": 15
},
"fieldConfig": {
"defaults": {
"unit": "ms",
"custom": {
"fillOpacity": 80
}
},
"overrides": []
},
"options": {
"bucketSize": 100,
"combine": false,
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"expr": "sum by (le, tool_name) (rate(pi_tool_duration_bucket{job=\"pi-coding-agent\"}[5m]))",
"legendFormat": "{{tool_name}}",
"refId": "A",
"format": "heatmap"
}
]
},
{
"type": "table",
"title": "Tool Performance Summary",
"description": "Average and p95 execution time per tool",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 23
},
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Avg Duration"
},
"properties": [
{
"id": "unit",
"value": "ms"
},
{
"id": "decimals",
"value": 1
}
]
},
{
"matcher": {
"id": "byName",
"options": "P95 Duration"
},
"properties": [
{
"id": "unit",
"value": "ms"
},
{
"id": "decimals",
"value": 1
}
]
},
{
"matcher": {
"id": "byName",
"options": "Error Rate"
},
"properties": [
{
"id": "unit",
"value": "percentunit"
},
{
"id": "decimals",
"value": 1
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0.05
}
]
}
},
{
"id": "custom.displayMode",
"value": "color-background"
}
]
}
]
},
"options": {
"footer": {
"enablePagination": false
}
},
"transformations": [
{
"id": "merge",
"options": {}
},
{
"id": "organize",
"options": {
"renameByName": {
"tool_name": "Tool",
"Value #A": "Total Calls",
"Value #B": "Avg Duration",
"Value #C": "P95 Duration",
"Value #D": "Error Rate"
}
}
}
],
"targets": [
{
"expr": "sum by (tool_name) (pi_tool_calls{job=\"pi-coding-agent\"})",
"legendFormat": "",
"refId": "A",
"instant": true,
"format": "table"
},
{
"expr": "sum by (tool_name) (pi_tool_duration_sum{job=\"pi-coding-agent\"}) / sum by (tool_name) (pi_tool_duration_count{job=\"pi-coding-agent\"})",
"legendFormat": "",
"refId": "B",
"instant": true,
"format": "table"
},
{
"expr": "histogram_quantile(0.95, sum by (le, tool_name) (rate(pi_tool_duration_bucket{job=\"pi-coding-agent\"}[1h])))",
"legendFormat": "",
"refId": "C",
"instant": true,
"format": "table"
},
{
"expr": "sum by (tool_name) (pi_tool_errors{job=\"pi-coding-agent\"}) / sum by (tool_name) (pi_tool_calls{job=\"pi-coding-agent\"})",
"legendFormat": "",
"refId": "D",
"instant": true,
"format": "table"
}
]
},
{
"type": "timeseries",
"title": "Tool Errors Over Time",
"description": "Failed tool executions per minute",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 23
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "bars",
"fillOpacity": 80
},
"unit": "short",
"color": {
"mode": "fixed",
"fixedColor": "red"
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"expr": "sum by (tool_name) (rate(pi_tool_errors{job=\"pi-coding-agent\"}[5m])) * 60",
"legendFormat": "{{tool_name}}",
"refId": "A"
}
]
},
{
"type": "row",
"title": "Agent Activity",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 31
},
"collapsed": false,
"panels": []
},
{
"type": "timeseries",
"title": "Prompts & Turns Rate",
"description": "User prompts and LLM turns per minute",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 15,
"pointSize": 5,
"showPoints": "auto"
},
"unit": "short"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Prompts"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "green",
"mode": "fixed"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Turns"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "blue",
"mode": "fixed"
}
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"expr": "sum(rate(pi_prompts{job=\"pi-coding-agent\"}[5m])) * 60",
"legendFormat": "Prompts",
"refId": "A"
},
{
"expr": "sum(rate(pi_turns{job=\"pi-coding-agent\"}[5m])) * 60",
"legendFormat": "Turns",
"refId": "B"
}
]
},
{
"type": "timeseries",
"title": "Session Duration",
"description": "Session duration over time (p50, p95)",
"datasource": {
"type": "prometheus",
"uid": "mCUDBhx4z"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 32
},
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 10,
"showPoints": "auto"
},
"unit": "s"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "p50"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "green",
"mode": "fixed"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "p95"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "orange",
"mode": "fixed"
}
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"expr": "histogram_quantile(0.5, sum(rate(pi_session_duration_bucket{job=\"pi-coding-agent\"}[1h])) by (le))",
"legendFormat": "p50",
"refId": "A"
},
{
"expr": "histogram_quantile(0.95, sum(rate(pi_session_duration_bucket{job=\"pi-coding-agent\"}[1h])) by (le))",
"legendFormat": "p95",
"refId": "B"
}
]
},
{
"type": "row",
"title": "Traces",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 40
},
"collapsed": false,
"panels": []
},
{
"type": "table",
"title": "Recent Sessions (Traces)",
"description": "Recent session traces from Tempo \u2014 click trace ID to explore",
"datasource": {
"type": "tempo",
"uid": "tempo"
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 41
},
"fieldConfig": {
"defaults": {},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Duration"
},
"properties": [
{
"id": "unit",
"value": "ns"
}
]
},
{
"matcher": {
"id": "byName",
"options": "Trace ID"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "View trace",
"url": "/explore?left=%7B%22datasource%22:%22tempo%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22queryType%22:%22traceql%22,%22query%22:%22${__value.raw}%22%7D%5D%7D"
}
]
}
]
}
]
},
"options": {
"footer": {
"enablePagination": true
},
"frameIndex": 0
},
"targets": [
{
"datasource": {
"type": "tempo",
"uid": "tempo"
},
"queryType": "traceql",
"query": "{ resource.service.name = \"pi-coding-agent\" }",
"limit": 20,
"refId": "A"
}
]
}
],
"refresh": "30s",
"schemaVersion": 39,
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"version": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment