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.
This commit is contained in:
2026-10-06 17:12:28 +07:00
parent 837da6e5de
commit 4aae61297f
146 changed files with 13565 additions and 537 deletions
@@ -0,0 +1,666 @@
{
"uid": "agenthub-overview",
"title": "AgentHub — Overview",
"description": "Health, activity and spend of one AgentHub dashboard (/api/metrics).",
"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": "Dashboard up",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 4,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "max(agenthub_up)",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 2,
"type": "stat",
"title": "Version",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 4,
"y": 0,
"w": 4,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "agenthub_build_info",
"legendFormat": "{{version}}",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"textMode": "name",
"colorMode": "none",
"graphMode": "none"
}
},
{
"id": 3,
"type": "stat",
"title": "Active sessions",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 8,
"y": 0,
"w": 4,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_sessions{status=\"active\"})",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 4,
"type": "stat",
"title": "Working agents",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 4,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_agents{status=\"working\"})",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 5,
"type": "stat",
"title": "Tokens (24h)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 16,
"y": 0,
"w": 4,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(increase(agenthub_tokens_total[24h]))",
"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": 6,
"type": "stat",
"title": "Spend (24h)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 20,
"y": 0,
"w": 4,
"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": 7,
"type": "timeseries",
"title": "Sessions by status",
"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 (status) (agenthub_sessions)",
"legendFormat": "{{status}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 8,
"type": "timeseries",
"title": "Agents by status",
"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 (status) (agenthub_agents)",
"legendFormat": "{{status}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 9,
"type": "timeseries",
"title": "Events per minute",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 12,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(rate(agenthub_events_total[5m])) * 60",
"legendFormat": "events/min"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 10,
"type": "timeseries",
"title": "Token burn (per second, by kind)",
"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 (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": 11,
"type": "timeseries",
"title": "Server memory (RSS)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 20,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "agenthub_process_resident_memory_bytes",
"legendFormat": "rss"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 12,
"type": "timeseries",
"title": "Server uptime",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 8,
"y": 20,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "agenthub_process_uptime_seconds",
"legendFormat": "uptime"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 13,
"type": "timeseries",
"title": "Realtime clients / remote sources",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 16,
"y": 20,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "agenthub_websocket_clients",
"legendFormat": "websocket clients"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (enabled) (agenthub_remote_sources)",
"legendFormat": "remote sources (auto-sync {{enabled}})"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
}
]
}
@@ -0,0 +1,490 @@
{
"uid": "agenthub-sessions-agents",
"title": "AgentHub — Sessions & agents",
"description": "Session and agent lifecycle counts from /api/metrics.",
"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": "Sessions (all)",
"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_sessions)",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 2,
"type": "stat",
"title": "Active",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 6,
"y": 0,
"w": 6,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_sessions{status=\"active\"})",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 3,
"type": "stat",
"title": "Errored sessions",
"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_sessions{status=\"error\"})",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 4,
"type": "stat",
"title": "Waiting agents (need you)",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 18,
"y": 0,
"w": 6,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_agents{status=\"waiting\"})",
"legendFormat": "__auto",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 1
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
}
},
{
"id": 5,
"type": "bargauge",
"title": "Sessions now, by status",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 4,
"w": 12,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (status) (agenthub_sessions)",
"legendFormat": "{{status}}",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"options": {
"orientation": "horizontal",
"displayMode": "gradient",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
}
}
},
{
"id": 6,
"type": "bargauge",
"title": "Agents now, by status",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 12,
"y": 4,
"w": 12,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (status) (agenthub_agents)",
"legendFormat": "{{status}}",
"instant": true,
"range": false
}
],
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"options": {
"orientation": "horizontal",
"displayMode": "gradient",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
}
}
},
{
"id": 7,
"type": "timeseries",
"title": "Active sessions and working agents",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 11,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_sessions{status=\"active\"})",
"legendFormat": "active sessions"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_agents{status=\"working\"})",
"legendFormat": "working agents"
},
{
"refId": "C",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(agenthub_agents{status=\"waiting\"})",
"legendFormat": "waiting agents"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 8,
"type": "timeseries",
"title": "Sessions finished per hour",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 12,
"y": 11,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum by (status) (clamp_min(delta(agenthub_sessions{status=~\"completed|error|abandoned\"}[1h]), 0))",
"legendFormat": "{{status}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"custom": {
"drawStyle": "bars",
"fillOpacity": 60,
"stacking": {
"mode": "normal"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 9,
"type": "timeseries",
"title": "Events per minute",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"gridPos": {
"x": 0,
"y": 19,
"w": 24,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "${ds}"
},
"expr": "sum(rate(agenthub_events_total[5m])) * 60",
"legendFormat": "events/min"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"custom": {
"fillOpacity": 15,
"lineWidth": 2,
"stacking": {
"mode": "none"
}
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
}
}
]
}
@@ -0,0 +1,462 @@
{
"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
}
}
}
]
}
@@ -0,0 +1,14 @@
# Loads the AgentHub boards (overview, sessions & agents, tokens & cost) from
# /var/lib/grafana/dashboards, the compose file's mount of monitoring/grafana/dashboards.
apiVersion: 1
providers:
- name: AgentHub
orgId: 1
folder: AgentHub
type: file
disableDeletion: false
updateIntervalSeconds: 30
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,13 @@
# The Prometheus datasource for docker-compose.monitoring.yml. The boards pick
# their datasource through a `ds` variable, so they also import into any other
# Grafana as they are.
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
uid: agenthub-prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true
+27
View File
@@ -0,0 +1,27 @@
# Recording rules over AgentHub's /api/metrics series (docs/MONITORING.md).
# The agenthub:cost_usd:* rules need agenthub_cost_usd_total{tool,model}; on a
# dashboard that does not export it they simply record nothing.
groups:
- name: agenthub_recording
interval: 30s
rules:
- record: agenthub:sessions:total
expr: sum(agenthub_sessions)
- record: agenthub:sessions:active
expr: sum(agenthub_sessions{status="active"})
- record: agenthub:agents:working
expr: sum(agenthub_agents{status="working"})
- record: agenthub:agents:waiting
expr: sum(agenthub_agents{status="waiting"})
- record: agenthub:events:rate5m
expr: sum(rate(agenthub_events_total[5m]))
- record: agenthub:tokens:rate5m
expr: sum by (kind) (rate(agenthub_tokens_total[5m]))
- record: agenthub:tokens:total
expr: sum(agenthub_tokens_total)
- record: agenthub:cost_usd:total
expr: sum(agenthub_cost_usd_total)
- record: agenthub:cost_usd:increase1h
expr: sum by (tool) (increase(agenthub_cost_usd_total[1h]))
- record: agenthub:cost_usd:increase24h
expr: sum by (tool, model) (increase(agenthub_cost_usd_total[24h]))
+26
View File
@@ -0,0 +1,26 @@
# Prometheus scrape config for AgentHub's /api/metrics (see docs/MONITORING.md).
#
# As shipped it is the config docker-compose.monitoring.yml mounts: Prometheus
# runs in a container and reaches the dashboard on the HOST through
# host.docker.internal. For a Prometheus running natively on the same machine,
# change the target to "127.0.0.1:4820".
#
# The dashboard's DNS-rebinding guard answers 403 EBADHOST to any Host header
# that is not loopback, so a container scrape needs the dashboard started with
# DASHBOARD_ALLOWED_HOSTS=host.docker.internal
# and, when DASHBOARD_TOKEN is set, the authorization block below.
global:
scrape_interval: 15s
scrape_timeout: 10s
rule_files:
- agenthub-rules.yml
scrape_configs:
- job_name: agenthub
metrics_path: /api/metrics
static_configs:
- targets: ["host.docker.internal:4820"]
# authorization:
# type: Bearer
# credentials_file: /etc/prometheus/dashboard-token