Watch
0
0
Fork
You've already forked hyperhive
0

Compare commits

...
Author SHA1 Message Date
iris
c9ba906284 swarm-grafana: replace busiest-agents bargauges with an actual table
mara: 'i asked for a table. ask when doing something different.' Right
call — the PR body flagged the bargauge substitution as an open question,
not a decision, and I should have waited for an answer instead of
treating the silent absence of an objection as one.

Single 'Busiest agents' table panel (replaces the 5 per-metric bargauges):
5 table-format instant queries (turns, input, output, cache-read, cost)
joined on the agent label (joinByField), renamed to the screenshot's own
column names via organize, sorted by turns descending via sortBy — same
column set and sort order as the attached /stats screenshot.

This is a genuinely novel schema shape for this repo: no table panel,
transformation, or field-override config exists anywhere else in
nix/host-modules/swarm-grafana/dashboards/*.json to verify the join/
organize/sortBy option shapes against. Structurally verified (valid
JSON, jq empty, unique panel ids, every panel referenced exactly once,
nix fmt clean, dashboard-description lint clean) but the join/rename
field-name mechanics (whether Grafana names the joined columns exactly
'Value #A'/'Value #B'/etc.) are built from general Grafana schema
knowledge, not a working local precedent — flagging that explicitly so
the actual render gets checked before merge.
2026-09-20 23:40:21 +02:00
iris
3a58bf59ba swarm-grafana: drop overview tab, fold panels into activity/cost
Reworked per review feedback: no new tab, and 3 of the added stat
panels duplicated existing ones (Active agents ~ panel-1 Agents
reporting, Cost = panel-2 Cost verbatim, Tokens ~ panel-3 + the new
input/output/cache-read breakdown). Removed panel-50/52/56 and the
overview tab entirely.

What's left is genuinely new (no prior panel covered it): a Turns KPI
and turns-by-agent bargauge in the activity tab (hyperhive.agent.turn.count
was emitted but unused anywhere), and input/output/cache-read token KPIs
plus cost/input/output/cache-read-by-agent bargauges in the cost tab
(the existing cost/token panels have no per-agent breakdown, and none
sort busiest-first).
2026-09-20 23:35:15 +02:00
iris
c5110c5ce2 swarm-grafana: agent-usage overview panels
New 'overview' tab on the agents dashboard, extending it per the
hive stats page's own summary layout (busiest-agents table + top KPI
row):

- KPI row: active agents, turns, tokens (all types), input, output,
  cache-read tokens, cost. All from metrics already flowing into
  this dashboard (claude_code.token.usage / claude_code.cost.usage /
  claude_code.session.count) plus hyperhive.agent.turn.count, which
  the harness already emits but nothing visualized yet.
- Busiest-agents replicated as five sorted bargauge panels (turns,
  cost, input, output, cache-read, each by agent) rather than one
  literal multi-column table -- this schema (Grafana v2beta1) has no
  existing table+merge-transform panel anywhere in this repo to
  pattern-match against, and every other panel here follows the
  proven sort_desc(...) + bargauge shape already used for
  'Cost by subagent name' (panel-43). Trading the exact table layout
  for schema I can verify against a working precedent.
- Left out the stats page's 'window' tile -- redundant with the
  dashboard's own always-visible time-range picker.

No new instrumentation needed. Structurally verified (valid JSON, no
duplicate panel ids, every panel referenced exactly once in the
layout) but not visually verified -- no local Grafana to render
against.
2026-09-20 23:18:28 +02:00

View file

@ -1478,6 +1478,503 @@
}
}
}
},
"panel-51": {
"kind": "Panel",
"spec": {
"id": 51,
"title": "Turns",
"description": "Total agent turns in the selected range.",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum(increase({__name__=\"hyperhive.agent.turn.count\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))",
"instant": true,
"legendFormat": "turns"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "stat",
"version": "",
"spec": {
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"textMode": "value"
},
"fieldConfig": {
"defaults": {
"unit": "short",
"decimals": 0,
"color": {
"mode": "fixed",
"fixedColor": "text"
}
},
"overrides": []
}
}
}
}
},
"panel-53": {
"kind": "Panel",
"spec": {
"id": 53,
"title": "Input tokens",
"description": "Input tokens in the selected range.",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum(increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"input\"}[$__range]))",
"instant": true,
"legendFormat": "input"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "stat",
"version": "",
"spec": {
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"textMode": "value"
},
"fieldConfig": {
"defaults": {
"unit": "short",
"decimals": 1,
"color": {
"mode": "fixed",
"fixedColor": "text"
}
},
"overrides": []
}
}
}
}
},
"panel-54": {
"kind": "Panel",
"spec": {
"id": 54,
"title": "Output tokens",
"description": "Output tokens in the selected range.",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum(increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"output\"}[$__range]))",
"instant": true,
"legendFormat": "output"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "stat",
"version": "",
"spec": {
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"textMode": "value"
},
"fieldConfig": {
"defaults": {
"unit": "short",
"decimals": 1,
"color": {
"mode": "fixed",
"fixedColor": "text"
}
},
"overrides": []
}
}
}
}
},
"panel-55": {
"kind": "Panel",
"spec": {
"id": 55,
"title": "Cache read tokens",
"description": "Cache-read tokens in the selected range.",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum(increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"cacheRead\"}[$__range]))",
"instant": true,
"legendFormat": "cache read"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "stat",
"version": "",
"spec": {
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"textMode": "value"
},
"fieldConfig": {
"defaults": {
"unit": "short",
"decimals": 1,
"color": {
"mode": "fixed",
"fixedColor": "text"
}
},
"overrides": []
}
}
}
}
},
"panel-60": {
"kind": "Panel",
"spec": {
"id": 60,
"title": "Busiest agents",
"description": "Per-agent turns, tokens and cost in the selected range, busiest first.",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) (increase({__name__=\"hyperhive.agent.turn.count\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))",
"instant": true,
"format": "table",
"legendFormat": "__auto"
}
},
"refId": "A",
"hidden": false
}
},
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) (increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"input\"}[$__range]))",
"instant": true,
"format": "table",
"legendFormat": "__auto"
}
},
"refId": "B",
"hidden": false
}
},
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) (increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"output\"}[$__range]))",
"instant": true,
"format": "table",
"legendFormat": "__auto"
}
},
"refId": "C",
"hidden": false
}
},
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) (increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"cacheRead\"}[$__range]))",
"instant": true,
"format": "table",
"legendFormat": "__auto"
}
},
"refId": "D",
"hidden": false
}
},
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) (increase({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))",
"instant": true,
"format": "table",
"legendFormat": "__auto"
}
},
"refId": "E",
"hidden": false
}
}
],
"transformations": [
{
"id": "joinByField",
"options": {
"byField": "agent",
"mode": "outer"
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true
},
"indexByName": {
"agent": 0,
"Value #A": 1,
"Value #B": 2,
"Value #C": 3,
"Value #D": 4,
"Value #E": 5
},
"renameByName": {
"Value #A": "turns",
"Value #B": "input",
"Value #C": "output",
"Value #D": "cache read",
"Value #E": "est cost"
}
}
},
{
"id": "sortBy",
"options": {
"fields": {},
"sort": [
{
"field": "turns",
"desc": true
}
]
}
}
],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "table",
"version": "",
"spec": {
"options": {
"showHeader": true,
"cellHeight": "sm",
"footer": {
"show": false,
"reducer": ["sum"],
"countRows": false
}
},
"fieldConfig": {
"defaults": {
"unit": "short",
"decimals": 1,
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "turns"
},
"properties": [
{
"id": "unit",
"value": "short"
},
{
"id": "decimals",
"value": 0
}
]
},
{
"matcher": {
"id": "byName",
"options": "est cost"
},
"properties": [
{
"id": "unit",
"value": "currencyUSD"
},
{
"id": "decimals",
"value": 2
}
]
}
]
}
}
}
}
}
},
"layout": {
@ -1543,6 +2040,32 @@
"name": "panel-32"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 11,
"width": 24,
"height": 4,
"element": {
"kind": "ElementReference",
"name": "panel-51"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 15,
"width": 24,
"height": 10,
"element": {
"kind": "ElementReference",
"name": "panel-60"
}
}
}
]
}
@ -1608,6 +2131,45 @@
"name": "panel-21"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 12,
"width": 8,
"height": 4,
"element": {
"kind": "ElementReference",
"name": "panel-53"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 8,
"y": 12,
"width": 8,
"height": 4,
"element": {
"kind": "ElementReference",
"name": "panel-54"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 16,
"y": 12,
"width": 8,
"height": 4,
"element": {
"kind": "ElementReference",
"name": "panel-55"
}
}
}
]
}