Add an Up for panel to the generated Grafana dashboard

One tile per server, time() - homelab_server_boot_time_seconds, in the Servers
row and following the Server picker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-08 21:59:59 +01:00
1 parent 48aea747bc
commit 8f5068c6e0
3 files changed
+12 -2

No files matched your search

+1 -1
View File
@@ -117,7 +117,7 @@ The dashboard has a **Server** picker (filled from `homelab_server_up`) and five
| Row | What it has | | Row | What it has |
|---|---| |---|---|
| **Needs attention** | Critical alerts, warnings, acknowledged, open incidents, servers down and up, integrations failing, maintenance, stale and failed backups, failed services, updates waiting, restarts needed; alerts over time; each integration's state. | | **Needs attention** | Critical alerts, warnings, acknowledged, open incidents, servers down and up, integrations failing, maintenance, stale and failed backups, failed services, updates waiting, restarts needed; alerts over time; each integration's state. |
| **Servers** | One table (up, CPU, memory, updates, security updates, failed services, agent behind), CPU and memory over time, 30-day uptime, time since each agent last reported. | | **Servers** | One table (up, CPU, memory, updates, security updates, failed services, agent behind), a tile per server for how long it has been up since it last started (for servers whose agent reports it), CPU and memory over time, 30-day uptime, time since each agent last reported. |
| **Disks** | Usage with a 90% line, disks filling up (days to full), SMART health, SSD life used, disk temperature, ZFS pools. | | **Disks** | Usage with a 90% line, disks filling up (days to full), SMART health, SSD life used, disk temperature, ZFS pools. |
| **Backups** | Guests by backup state, the age of each newest backup, and the age, last result and count of Homelab Manager's own backups. | | **Backups** | Guests by backup state, the age of each newest backup, and the age, last result and count of Homelab Manager's own backups. |
| **Secrets, power and the app itself** | Secrets and certificates by days left, the inventory's power draw, how long `/metrics` takes to build. | | **Secrets, power and the app itself** | Secrets and certificates by days left, the inventory's power draw, how long `/metrics` takes to build. |
+1
View File
@@ -200,6 +200,7 @@ export function buildGrafanaDashboard(): Record<string, unknown> {
24, 24,
9, 9,
); );
l.add(stat("Up for", `time() - homelab_server_boot_time_seconds${srv}`, { unit: "s", legend: "{{server}}", description: "How long each server has run since it last started, from the uptime its agent reports. A tile that has just reset is a server that has just rebooted." }), 24, 4);
l.add(timeseries("CPU load", [{ expr: `homelab_server_cpu_load_percent${srv}`, legend: "{{server}}" }], { unit: "percent", min: 0 }), 12, 8); l.add(timeseries("CPU load", [{ expr: `homelab_server_cpu_load_percent${srv}`, legend: "{{server}}" }], { unit: "percent", min: 0 }), 12, 8);
l.add(timeseries("Memory in use", [{ expr: `homelab_server_memory_used_percent${srv}`, legend: "{{server}}" }], { unit: "percent", min: 0, max: 100 }), 12, 8); l.add(timeseries("Memory in use", [{ expr: `homelab_server_memory_used_percent${srv}`, legend: "{{server}}" }], { unit: "percent", min: 0, max: 100 }), 12, 8);
l.add(bargauge("Uptime, last 30 days", `homelab_server_uptime_ratio_30d${srv}`, "{{server}}", { unit: "percentunit", min: 0, max: 1, thresholds: { steps: [[RED, null], [YELLOW, 0.95], [GREEN, 0.99]] } }), 12, 8); l.add(bargauge("Uptime, last 30 days", `homelab_server_uptime_ratio_30d${srv}`, "{{server}}", { unit: "percentunit", min: 0, max: 1, thresholds: { steps: [[RED, null], [YELLOW, 0.95], [GREEN, 0.99]] } }), 12, 8);
+10 -1
View File
@@ -95,10 +95,19 @@ describe("what it asks for", () => {
for (const m of [ for (const m of [
"homelab_alerts", "homelab_incidents_open", "homelab_server_up", "homelab_server_disk_used_percent", "homelab_server_disk_days_to_full", "homelab_server_disk_healthy", "homelab_alerts", "homelab_incidents_open", "homelab_server_up", "homelab_server_disk_used_percent", "homelab_server_disk_days_to_full", "homelab_server_disk_healthy",
"homelab_server_zfs_pool_online", "homelab_backup_guests", "homelab_backup_last_age_seconds", "homelab_selfbackup_last_success_timestamp_seconds", "homelab_secret_expiry_days", "homelab_server_zfs_pool_online", "homelab_backup_guests", "homelab_backup_last_age_seconds", "homelab_selfbackup_last_success_timestamp_seconds", "homelab_secret_expiry_days",
"homelab_integration_up", "homelab_server_uptime_ratio_30d", "homelab_server_pending_updates", "homelab_integration_up", "homelab_server_uptime_ratio_30d", "homelab_server_pending_updates", "homelab_server_boot_time_seconds",
]) assert.ok(asked.has(m), `${m} has no panel`); ]) assert.ok(asked.has(m), `${m} has no panel`);
}); });
test("a server's time since it last started is shown, per server, in seconds, and follows the Server picker", () => {
const p = panels.find((x) => x.title === "Up for")!;
assert.ok(p, "there is an Up for panel");
assert.equal(p.type, "stat");
assert.equal(p.targets![0].expr, 'time() - homelab_server_boot_time_seconds{server=~"$server"}');
assert.equal(p.targets![0].legendFormat, "{{server}}");
assert.equal((p as unknown as { fieldConfig: { defaults: { unit: string } } }).fieldConfig.defaults.unit, "s");
});
test("each query is well-formed: not empty, brackets and quotes balanced, no stray template text", () => { test("each query is well-formed: not empty, brackets and quotes balanced, no stray template text", () => {
for (const p of withQueries) { for (const p of withQueries) {
for (const t of p.targets!) { for (const t of p.targets!) {