From b6d0790eb4bc8e2ad45dc6f5a56ded6ac20db978 Mon Sep 17 00:00:00 2001 From: damocles Date: Sun, 22 Nov 2026 21:37:22 +0100 Subject: [PATCH] grafana: the claude usage panel keeps the history from before the account label as an unlabelled account --- nix/host-modules/swarm-grafana/dashboards/claude-usage.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/host-modules/swarm-grafana/dashboards/claude-usage.json b/nix/host-modules/swarm-grafana/dashboards/claude-usage.json index 312b28596..dc23b5709 100644 --- a/nix/host-modules/swarm-grafana/dashboards/claude-usage.json +++ b/nix/host-modules/swarm-grafana/dashboards/claude-usage.json @@ -1030,7 +1030,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "max by (account, window) ({__name__=\"hyperhive.agent.claude_usage.percent\", account!=\"\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"} unless on(agent, hive, window) ({__name__=\"hyperhive.agent.claude_usage.resets_at\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"} < time()))", + "expr": "label_replace(max by (account, window) ({__name__=\"hyperhive.agent.claude_usage.percent\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"} unless on(agent, hive, window) ({__name__=\"hyperhive.agent.claude_usage.resets_at\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"} < time())), \"account\", \"unlabelled\", \"account\", \"\")", "legendFormat": "{{account}} · {{window}} used" }, { @@ -1039,7 +1039,7 @@ "type": "prometheus", "uid": "@datasourceUid@" }, - "expr": "(100 * (1 - (max by (account, window) ({__name__=\"hyperhive.agent.claude_usage.resets_at\", account!=\"\", window=\"seven_day\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"}) - time()) / 604800)) < 100 or (100 * (1 - (max by (account, window) ({__name__=\"hyperhive.agent.claude_usage.resets_at\", account!=\"\", window=\"five_hour\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"}) - time()) / 18000)) < 100", + "expr": "label_replace((100 * (1 - (max by (account, window) ({__name__=\"hyperhive.agent.claude_usage.resets_at\", window=\"seven_day\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"}) - time()) / 604800)) < 100 or (100 * (1 - (max by (account, window) ({__name__=\"hyperhive.agent.claude_usage.resets_at\", window=\"five_hour\", hive=~\"$hive\", \"service.name\"=~\"$service\", agent=~\"$agent\"}) - time()) / 18000)) < 100, \"account\", \"unlabelled\", \"account\", \"\")", "legendFormat": "{{account}} · {{window}} elapsed" } ],