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" } ],