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.
This commit is contained in:
atlas 2026-08-23 22:48:23 +02:00 committed by mara
commit 0ddb504a98

View file

@ -17,6 +17,25 @@
}, },
"templating": { "templating": {
"list": [ "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", "name": "agent",
"label": "Agent", "label": "Agent",
@ -25,7 +44,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "uid": "@datasourceUid@"
}, },
"query": "label_values({__name__=\"hyperhive.container.cpu.percent\"}, agent)", "query": "label_values({__name__=\"hyperhive.container.cpu.percent\", hive=~\"$hive\"}, agent)",
"refresh": 2, "refresh": 2,
"includeAll": true, "includeAll": true,
"allValue": ".*", "allValue": ".*",
@ -61,7 +80,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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, "instant": true,
"legendFormat": "agents" "legendFormat": "agents"
} }
@ -114,7 +133,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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, "instant": true,
"legendFormat": "cost" "legendFormat": "cost"
} }
@ -166,7 +185,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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, "instant": true,
"legendFormat": "tokens" "legendFormat": "tokens"
} }
@ -218,7 +237,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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, "instant": true,
"legendFormat": "sessions" "legendFormat": "sessions"
} }
@ -271,7 +290,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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}}" "legendFormat": "{{agent}}"
} }
], ],
@ -328,7 +347,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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}}" "legendFormat": "{{agent}}"
} }
], ],
@ -384,7 +403,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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}}" "legendFormat": "{{agent}}"
} }
], ],
@ -441,7 +460,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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}}" "legendFormat": "{{model}}"
} }
], ],
@ -498,7 +517,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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, "instant": true,
"legendFormat": "{{agent}}" "legendFormat": "{{agent}}"
} }
@ -559,7 +578,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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}}" "legendFormat": "{{type}}"
} }
], ],
@ -616,7 +635,7 @@
"type": "prometheus", "type": "prometheus",
"uid": "@datasourceUid@" "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, "instant": true,
"legendFormat": "{{agent}}" "legendFormat": "{{agent}}"
} }