From 0ddb504a986b649385db152bc61fc546d8098dc8 Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 23 Aug 2026 22:48:23 +0200 Subject: [PATCH] feat(#3494): filter the agents dashboard by hive The operator asked for this when the dashboard was first reviewed and it was deferred, not declined: the container metric family carried no hive label, so selecting a hive emptied every container panel while the "All" default hid the problem completely -- a `.*` matcher matches series where the label is absent. That family now carries hive and swarm, verified against the live store rather than inferred from the fix having merged: a hive selection returns the same 7 agents as the All default, at every window out to 168h, with a nonexistent hive returning zero. The agent list chains off the hive selection, so picking a hive narrows the agent dropdown rather than leaving entries in it that resolve to nothing. --- .../swarm-grafana/dashboards/agents.json | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/nix/host-modules/swarm-grafana/dashboards/agents.json b/nix/host-modules/swarm-grafana/dashboards/agents.json index 416288e3..0a94fdd8 100644 --- a/nix/host-modules/swarm-grafana/dashboards/agents.json +++ b/nix/host-modules/swarm-grafana/dashboards/agents.json @@ -17,6 +17,25 @@ }, "templating": { "list": [ + { + "name": "hive", + "label": "Hive", + "type": "query", + "datasource": { + "type": "prometheus", + "uid": "@datasourceUid@" + }, + "query": "label_values({__name__=\"hyperhive.container.cpu.percent\"}, hive)", + "refresh": 2, + "includeAll": true, + "allValue": ".*", + "multi": true, + "current": { + "text": "All", + "value": "$__all" + }, + "sort": 1 + }, { "name": "agent", "label": "Agent", @@ -25,7 +44,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "query": "label_values({__name__=\"hyperhive.container.cpu.percent\"}, agent)", + "query": "label_values({__name__=\"hyperhive.container.cpu.percent\", hive=~\"$hive\"}, agent)", "refresh": 2, "includeAll": true, "allValue": ".*", @@ -61,7 +80,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "count(count by (agent) ({__name__=\"hyperhive.container.cpu.percent\", agent=~\"$agent\"}))", + "expr": "count(count by (agent) ({__name__=\"hyperhive.container.cpu.percent\", hive=~\"$hive\", agent=~\"$agent\"}))", "instant": true, "legendFormat": "agents" } @@ -114,7 +133,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum(increase({__name__=\"claude_code.cost.usage\", agent=~\"$agent\"}[$__range]))", + "expr": "sum(increase({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))", "instant": true, "legendFormat": "cost" } @@ -166,7 +185,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum(increase({__name__=\"claude_code.token.usage\", agent=~\"$agent\", type!=\"cacheRead\"}[$__range]))", + "expr": "sum(increase({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type!=\"cacheRead\"}[$__range]))", "instant": true, "legendFormat": "tokens" } @@ -218,7 +237,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum(increase({__name__=\"claude_code.session.count\", agent=~\"$agent\"}[$__range]))", + "expr": "sum(increase({__name__=\"claude_code.session.count\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))", "instant": true, "legendFormat": "sessions" } @@ -271,7 +290,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum by (agent) (rate({__name__=\"claude_code.cost.usage\", agent=~\"$agent\"}[$__rate_interval])) * 3600", + "expr": "sum by (agent) (rate({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\"}[$__rate_interval])) * 3600", "legendFormat": "{{agent}}" } ], @@ -328,7 +347,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum by (agent) ({__name__=\"hyperhive.container.cpu.percent\", agent=~\"$agent\"})", + "expr": "sum by (agent) ({__name__=\"hyperhive.container.cpu.percent\", hive=~\"$hive\", agent=~\"$agent\"})", "legendFormat": "{{agent}}" } ], @@ -384,7 +403,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum by (agent) ({__name__=\"container.memory.usage\", agent=~\"$agent\"})", + "expr": "sum by (agent) ({__name__=\"container.memory.usage\", hive=~\"$hive\", agent=~\"$agent\"})", "legendFormat": "{{agent}}" } ], @@ -441,7 +460,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum by (model) (rate({__name__=\"claude_code.token.usage\", agent=~\"$agent\", type!=\"cacheRead\"}[$__rate_interval])) * 60", + "expr": "sum by (model) (rate({__name__=\"claude_code.token.usage\", hive=~\"$hive\", agent=~\"$agent\", type!=\"cacheRead\"}[$__rate_interval])) * 60", "legendFormat": "{{model}}" } ], @@ -498,7 +517,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum by (agent) ({__name__=\"hyperhive.container.storage.usage\", agent=~\"$agent\"})", + "expr": "sum by (agent) ({__name__=\"hyperhive.container.storage.usage\", hive=~\"$hive\", agent=~\"$agent\"})", "instant": true, "legendFormat": "{{agent}}" } @@ -559,7 +578,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum by (type) (rate({__name__=\"claude_code.lines_of_code.count\", agent=~\"$agent\"}[$__rate_interval])) * 60", + "expr": "sum by (type) (rate({__name__=\"claude_code.lines_of_code.count\", hive=~\"$hive\", agent=~\"$agent\"}[$__rate_interval])) * 60", "legendFormat": "{{type}}" } ], @@ -616,7 +635,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "sum by (agent) (increase({__name__=\"claude_code.active_time.total\", agent=~\"$agent\"}[$__range]))", + "expr": "sum by (agent) (increase({__name__=\"claude_code.active_time.total\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))", "instant": true, "legendFormat": "{{agent}}" }