Files
AgentHub/monitoring/grafana/dashboards/agenthub-tokens-cost.json
T
nntrivi2001 4aae61297f feat: analytics parity — tool cost, date ranges, budgets, query explorer, replay, snapshots (v2.4.0)
Analytics parity phases 2–7 (docs/plans/analytics-parity/), built on
138e706 and ported onto v2.3.1:
- Cost by AI tool (?tool= on cost/analytics/stats/workflows, by_tool,
  Codex fast/priority and flex tiers, agenthub_cost_usd_total{tool,model})
- Date ranges (from/to) on cost/analytics/workflows; Analytics range select
  with Today / This week (Monday) / This month (1st) / 7d / 30d / 90d / All /
  Custom; workflow filters carried into workflow-stats.js (read worker)
- Budgets and cost alerts as alert rule types (alert_rules rebuilt without
  its rule_type CHECK), GET /api/budgets/status, rule preview, spend pace,
  status-bar budget chip; rules stay editable in place
- Query Explorer (/query, allowlisted sort, CSV/JSON export) and scheduled
  reports (report_definitions/report_runs, Settings → Reports)
- Session Replay tab and immutable snapshots (session_snapshots, /snapshot/:token)
- Remote Codex sync, push ingest with a hashed token, privacy redaction and
  ignored folders (Settings → Data), Cursor sessions (no cost)
- Read-only MCP server, statusline, Grafana/Prometheus files

Also: resizable sidebar, pet run/wave animations, the workspace home keeps a
half-typed prompt, and the pre-commit hook runs only the related tests for a
small commit.
2026-10-06 17:12:28 +07:00

463 lines
10 KiB
JSON

{
"uid": "agenthub-tokens-cost",
"title": "AgentHub — Tokens & cost",
"description": "Token usage by kind and estimated USD spend by tool and model.",
"tags": ["agenthub"],
"editable": true,
"schemaVersion": 39,
"version": 1,
"refresh": "30s",
"time": {
"from": "now-24h",
"to": "now"
},
"timezone": "browser",
"templating": {
"list": [
{
"name": "ds",
"label": "Prometheus",
"type": "datasource",
"query": "prometheus",
"current": {},
"hide": 0
}
]
},
"links": [
{
"title": "AgentHub boards",
"type": "dashboards",
"tags": ["agenthub"],
"asDropdown": true
}
],
"annotations": {
"list": []
},
"panels": [
{
"id": 1,
"type": "stat",
"title": "Tokens (all time)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 6,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_tokens_total)",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 2,
"type": "stat",
"title": "Cache read share (24h)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 6,
"y": 0,
"w": 6,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(increase(agenthub_tokens_total{kind=\"cache_read\"}[24h])) / sum(increase(agenthub_tokens_total{kind=~\"input|cache_read|cache_write\"}[24h]))",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"decimals": 1
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 3,
"type": "stat",
"title": "Spend (all time)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 6,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_cost_usd_total)",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "currencyUSD",
"decimals": 2
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
},
"description": "Requires agenthub_cost_usd_total{tool,model} — empty on a dashboard that does not export it yet."
},
{
"id": 4,
"type": "stat",
"title": "Spend (24h)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 18,
"y": 0,
"w": 6,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(increase(agenthub_cost_usd_total[24h]))",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "currencyUSD",
"decimals": 2
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
},
"description": "Requires agenthub_cost_usd_total{tool,model} — empty on a dashboard that does not export it yet."
},
{
"id": 5,
"type": "timeseries",
"title": "Tokens per hour, by kind",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 4,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (kind) (increase(agenthub_tokens_total[1h]))",
"legendFormat": "{{kind}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"drawStyle": "bars",
"fillOpacity": 60,
"stacking": {
"mode": "normal"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"interval": "1h"
},
{
"id": 6,
"type": "timeseries",
"title": "Token burn (per second, by kind)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 12,
"y": 4,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (kind) (rate(agenthub_tokens_total[5m]))",
"legendFormat": "{{kind}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "normal"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 7,
"type": "timeseries",
"title": "Spend per hour, by tool",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 12,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (tool) (increase(agenthub_cost_usd_total[1h]))",
"legendFormat": "{{tool}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "currencyUSD",
"custom": {
"drawStyle": "bars",
"fillOpacity": 60,
"stacking": {
"mode": "normal"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"interval": "1h",
"description": "Requires agenthub_cost_usd_total{tool,model} — empty on a dashboard that does not export it yet."
},
{
"id": 8,
"type": "piechart",
"title": "Spend by tool (all time)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 12,
"y": 12,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (tool) (agenthub_cost_usd_total)",
"legendFormat": "{{tool}}",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "currencyUSD",
"decimals": 2
},
"overrides": []
},
"description": "Requires agenthub_cost_usd_total{tool,model} — empty on a dashboard that does not export it yet.",
"options": {
"pieType": "donut",
"legend": {
"displayMode": "table",
"placement": "right",
"values": ["value", "percent"]
},
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
}
}
},
{
"id": 9,
"type": "bargauge",
"title": "Top models by spend (24h)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 20,
"w": 24,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "topk(10, sum by (model) (increase(agenthub_cost_usd_total[24h])))",
"legendFormat": "{{model}}",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "currencyUSD",
"decimals": 2
},
"overrides": []
},
"description": "Requires agenthub_cost_usd_total{tool,model} — empty on a dashboard that does not export it yet.",
"options": {
"orientation": "horizontal",
"displayMode": "gradient",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
}
}
}
]
}