Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Skip agent-sourced alerts in node-presence cleanup
rcourtman113190a920f7
diff --git a/internal/alerts/active_cleanup.go b/internal/alerts/active_cleanup.goindex 0c9d3b6ff7..a096ed5135 100644--- a/internal/alerts/active_cleanup.go+++ b/internal/alerts/active_cleanup.go@@ -252,6 +252,21 @@ func (m *Manager) CleanupAlertsForNodes(existingNodes map[string]bool) {if alert.CanonicalKind == string(alertspecs.AlertSpecKindConnectivity) && strings.HasPrefix(alert.ResourceID, "pbs") {continue}+ // Agent-sourced resources (Unraid, standalone Linux hosts, TrueNAS,+ // any platform reached via Pulse Agent) do not appear in the+ // existingNodes map — that map is built only from Proxmox nodes+ // and PBS instances. Without this carve-out, every cleanup cycle+ // removes the agent alert because alert.Node is empty or unmapped,+ // then the next poll re-creates the alert as "new", calls+ // AddAlert, and appends a fresh history row. Result observed in+ // the wild: 3,980 history entries in 7 days for what were really+ // a small number of persistent issues (e.g. an Unraid array+ // running without parity protection generating one entry per+ // 30-second poll). Agent resource IDs are namespaced as+ // "agent:<id>...", so this carve-out matches that pattern.+ if strings.HasPrefix(alert.ResourceID, "agent:") {+ continue+ }node := alert.Nodeif node == "" || !existingNodes[node] {diff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.goindex f3d020a8c3..0d266efcbc 100644--- a/internal/alerts/alerts_test.go+++ b/internal/alerts/alerts_test.go@@ -11316,6 +11316,62 @@ func TestCleanupAlertsForNodes(t *testing.T) {t.Errorf("expected 1 alert, got %d", count)}})++ t.Run("preserves agent-sourced alerts even when node not in existingNodes map", func(t *testing.T) {+ // Agent-sourced resources (Unraid, standalone Linux hosts, TrueNAS,+ // anything reached via Pulse Agent) do not appear in existingNodes+ // — that map is built from Proxmox nodes and PBS instances.+ // Without the agent: ResourceID carve-out, the cleanup pass+ // removes the alert every cycle and the next poll re-creates it+ // as new, calling AddAlert and appending a duplicate history row.+ // The 30-second cycle produces ~3,980 history entries in 7 days+ // for what should be a handful of persistent issues. This test+ // locks in the carve-out.+ m := newTestManager(t)++ m.mu.Lock()+ m.activeAlerts["agent-unraid-array"] = &Alert{+ ID: "agent-unraid-array",+ ResourceID: "agent:de6d3fee-2595-6c2b-6b08-43db6b0ab427/storage:unraid-array",+ Type: "storage-topology",+ Node: "", // Agent alerts often have no Proxmox-style node.+ }+ m.activeAlerts["agent-cpu"] = &Alert{+ ID: "agent-cpu",+ ResourceID: "agent:de6d3fee-2595-6c2b-6b08-43db6b0ab427",+ Type: "cpu",+ Node: "",+ }+ m.activeAlerts["proxmox-stale"] = &Alert{+ ID: "proxmox-stale",+ Node: "decommissioned-pve",+ }+ m.mu.Unlock()++ // Only the legitimate Proxmox nodes are in the map — neither agent+ // resource appears here, mirroring production behaviour where+ // existingNodes is sourced from state.Nodes + state.PBSInstances.+ existingNodes := map[string]bool{"pve1": true}++ m.CleanupAlertsForNodes(existingNodes)+ time.Sleep(50 * time.Millisecond)++ m.mu.RLock()+ _, unraidStays := testLookupActiveAlert(t, m, "agent-unraid-array")+ _, agentCPUStays := testLookupActiveAlert(t, m, "agent-cpu")+ _, staleStays := testLookupActiveAlert(t, m, "proxmox-stale")+ m.mu.RUnlock()++ if !unraidStays {+ t.Error("agent-sourced Unraid alert must survive cleanup; carve-out missing")+ }+ if !agentCPUStays {+ t.Error("agent-sourced CPU alert must survive cleanup; carve-out missing")+ }+ if staleStays {+ t.Error("non-agent alert with stale node must still be removed (control case)")+ }+ })}func TestCheckZFSPoolHealth(t *testing.T) {