swarm-grafana: sort multi-series bargauge panels by value

Bargauge panels display series in the order the datasource returns them —
Grafana has no native sort for that (long-standing upstream gap, grafana#17245).
The reliable fix is sorting at the PromQL level with sort_desc() on an
instant vector, which forge.json's 'Issues by label' panel already does.
Applies the same pattern to the other 14 multi-series bargauge panels across
agents.json, claude-usage.json, and authelia.json (the latter two also
needed instant: true added, since sort_desc only works on instant vectors).

logstore.json's two VictoriaLogs-backed bargauge panels use LogsQL, not
PromQL, and are left out of this pass — LogsQL's sort-after-stats has a
documented ordering bug in some versions; needs its own verification.
This commit is contained in:
iris 2026-09-18 01:25:29 +02:00 • committed by mara
commit c7f6c33321
3 changed files with 16 additions and 14 deletions

View file

@ -644,7 +644,7 @@
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) ({__name__=\"hyperhive.container.storage.usage\", hive=~\"$hive\", agent=~\"$agent\"})",
"expr": "sort_desc(sum by (agent) ({__name__=\"hyperhive.container.storage.usage\", hive=~\"$hive\", agent=~\"$agent\"}))",
"instant": true,
"legendFormat": "{{agent}}"
}
@ -795,7 +795,7 @@
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) (increase({__name__=\"claude_code.active_time.total\", hive=~\"$hive\", agent=~\"$agent\"}[$__range]))",
"expr": "sort_desc(sum by (agent) (increase({__name__=\"claude_code.active_time.total\", hive=~\"$hive\", agent=~\"$agent\"}[$__range])))",
"instant": true,
"legendFormat": "{{agent}}"
}
@ -1209,7 +1209,7 @@
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (subagent) (increase({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\", subagent!=\"\"}[$__range]))",
"expr": "sort_desc(sum by (subagent) (increase({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\", subagent!=\"\"}[$__range])))",
"instant": true,
"legendFormat": "{{subagent}}"
}
@ -1285,7 +1285,7 @@
"name": "@datasourceUid@"
},
"spec": {
"expr": "sum by (agent) (increase({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\", subagent!=\"\"}[$__range]))",
"expr": "sort_desc(sum by (agent) (increase({__name__=\"claude_code.cost.usage\", hive=~\"$hive\", agent=~\"$agent\", subagent!=\"\"}[$__range])))",
"instant": true,
"legendFormat": "{{agent}}"
}