From c9e12ffcc01dc447db320f2097cb4a7923375e11 Mon Sep 17 00:00:00 2001 From: iris Date: Mon, 28 Sep 2026 10:24:48 +0200 Subject: [PATCH] swarm-grafana: revert busiest-agents table, restore bargauges (#4658) c9ba9062 replaced 5 bargauge panels with one table panel using a joinByField+organize+sortBy transformations chain and a vizConfig.group="table" viz spec. That construct had zero precedent anywhere else in this repo's dashboards and its live render was explicitly flagged as unverified at merge time (no in-container way to render Grafana to confirm). #4658 reports a dashboard crash: "'' not found in: reduce, filterFieldsByName, ... transpose" - a Grafana transform-registry lookup failing on an empty transformer id. That registry's full id list matches the error text exactly, and the table panel is the only panel in the whole swarm-grafana/dashboards tree using a non-empty transformations array, so it's the leading suspect: some part of how the dashboard-v2beta1 schema expects a QueryGroup's transformations to be shaped likely differs from the classic {id, options} shape used here, and the file-based provisioner may not be normalizing the mismatch the same way a schema-v2-aware loader does. Reverting to the prior, previously-uneventful bargauge panels (byte-for-byte c9ba9062^'s version of this section) to stop the active crash while the correct v2beta1 transformation shape gets verified against a live Grafana render instead of guessed at again. --- .../swarm-grafana/dashboards/agents.json | 551 ++++++++++++------ 1 file changed, 377 insertions(+), 174 deletions(-) diff --git a/nix/host-modules/swarm-grafana/dashboards/agents.json b/nix/host-modules/swarm-grafana/dashboards/agents.json index ddeeac2d..39f0ba95 100644 --- a/nix/host-modules/swarm-grafana/dashboards/agents.json +++ b/nix/host-modules/swarm-grafana/dashboards/agents.json @@ -1751,8 +1751,8 @@ "kind": "Panel", "spec": { "id": 60, - "title": "Busiest agents", - "description": "Per-agent turns, tokens and cost in the selected range, busiest first.", + "title": "Turns by agent", + "description": "Agent turns in the selected range, busiest first.", "links": [], "data": { "kind": "QueryGroup", @@ -1769,208 +1769,359 @@ "name": "@datasourceUid@" }, "spec": { - "expr": "sum by (agent) (increase({__name__=\"hyperhive.agent.turn.count\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))", + "expr": "sort_desc(sum by (agent) (increase({__name__=\"hyperhive.agent.turn.count\", hive=~\"$hive\", agent=~\"$agent\"}[$__range])))", "instant": true, - "format": "table", - "legendFormat": "__auto" + "legendFormat": "{{agent}}" } }, "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 - } - ] - } } ], + "transformations": [], "queryOptions": {} } }, "vizConfig": { "kind": "VizConfig", - "group": "table", + "group": "bargauge", "version": "", "spec": { "options": { - "showHeader": true, - "cellHeight": "sm", - "footer": { - "show": false, - "reducer": ["sum"], - "countRows": false + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "valueMode": "text" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "value": null, + "color": "blue" + } + ] + }, + "color": { + "mode": "fixed", + "fixedColor": "blue" + } + }, + "overrides": [] + } + } + } + } + }, + "panel-61": { + "kind": "Panel", + "spec": { + "id": 61, + "title": "Cost by agent", + "description": "USD spent 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": "sort_desc(sum by (agent) (increase({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\"}[$__range])))", + "instant": true, + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "bargauge", + "version": "", + "spec": { + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "valueMode": "text" + }, + "fieldConfig": { + "defaults": { + "unit": "currencyUSD", + "decimals": 2, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "value": null, + "color": "purple" + } + ] + }, + "color": { + "mode": "fixed", + "fixedColor": "purple" + } + }, + "overrides": [] + } + } + } + } + }, + "panel-62": { + "kind": "Panel", + "spec": { + "id": 62, + "title": "Input tokens by agent", + "description": "Input tokens 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": "sort_desc(sum by (agent) (increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"input\"}[$__range])))", + "instant": true, + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "bargauge", + "version": "", + "spec": { + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "valueMode": "text" }, "fieldConfig": { "defaults": { "unit": "short", "decimals": 1, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "turns" - }, - "properties": [ + "thresholds": { + "mode": "absolute", + "steps": [ { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 0 + "value": null, + "color": "blue" } ] }, - { - "matcher": { - "id": "byName", - "options": "est cost" - }, - "properties": [ - { - "id": "unit", - "value": "currencyUSD" + "color": { + "mode": "fixed", + "fixedColor": "blue" + } + }, + "overrides": [] + } + } + } + } + }, + "panel-63": { + "kind": "Panel", + "spec": { + "id": 63, + "title": "Output tokens by agent", + "description": "Output tokens 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": "sort_desc(sum by (agent) (increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"output\"}[$__range])))", + "instant": true, + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "bargauge", + "version": "", + "spec": { + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "valueMode": "text" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 1, + "thresholds": { + "mode": "absolute", + "steps": [ { - "id": "decimals", - "value": 2 + "value": null, + "color": "blue" } ] + }, + "color": { + "mode": "fixed", + "fixedColor": "blue" } - ] + }, + "overrides": [] + } + } + } + } + }, + "panel-64": { + "kind": "Panel", + "spec": { + "id": 64, + "title": "Cache read tokens by agent", + "description": "Cache-read tokens 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": "sort_desc(sum by (agent) (increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type=\"cacheRead\"}[$__range])))", + "instant": true, + "legendFormat": "{{agent}}" + } + }, + "refId": "A", + "hidden": false + } + } + ], + "transformations": [], + "queryOptions": {} + } + }, + "vizConfig": { + "kind": "VizConfig", + "group": "bargauge", + "version": "", + "spec": { + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "valueMode": "text" + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 1, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "value": null, + "color": "blue" + } + ] + }, + "color": { + "mode": "fixed", + "fixedColor": "blue" + } + }, + "overrides": [] } } } @@ -2060,7 +2211,7 @@ "x": 0, "y": 15, "width": 24, - "height": 10, + "height": 8, "element": { "kind": "ElementReference", "name": "panel-60" @@ -2170,6 +2321,58 @@ "name": "panel-55" } } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 16, + "width": 12, + "height": 7, + "element": { + "kind": "ElementReference", + "name": "panel-61" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 12, + "y": 16, + "width": 12, + "height": 7, + "element": { + "kind": "ElementReference", + "name": "panel-62" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 0, + "y": 23, + "width": 12, + "height": 7, + "element": { + "kind": "ElementReference", + "name": "panel-63" + } + } + }, + { + "kind": "GridLayoutItem", + "spec": { + "x": 12, + "y": 23, + "width": 12, + "height": 7, + "element": { + "kind": "ElementReference", + "name": "panel-64" + } + } } ] }