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
Handle ignored docker containers during alert reevaluation (related to #561)
rcourtmane7f5b24f0550
diff --git a/internal/alerts/alerts.go b/internal/alerts/alerts.goindex 16884c08af..c3248a5626 100644--- a/internal/alerts/alerts.go+++ b/internal/alerts/alerts.go@@ -1422,6 +1422,20 @@ func (m *Manager) reevaluateActiveAlertsLocked() {alertsToResolve = append(alertsToResolve, alertID)continue}+ containerName := strings.ToLower(strings.TrimSpace(alert.ResourceName))+ containerID := ""+ if alert.Metadata != nil {+ if val, ok := alert.Metadata["containerId"].(string); ok {+ containerID = strings.ToLower(strings.TrimSpace(val))+ }+ if val, ok := alert.Metadata["containerName"].(string); ok && containerName == "" {+ containerName = strings.ToLower(strings.TrimSpace(val))+ }+ }+ if matchesDockerIgnoredPrefix(containerName, containerID, m.config.DockerIgnoredContainerPrefixes) {+ alertsToResolve = append(alertsToResolve, alertID)+ continue+ }thresholds := ThresholdConfig{CPU: cloneThreshold(&m.config.DockerDefaults.CPU),Memory: cloneThreshold(&m.config.DockerDefaults.Memory),diff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.goindex 0601a18a4e..b3772e979a 100644--- a/internal/alerts/alerts_test.go+++ b/internal/alerts/alerts_test.go@@ -1845,3 +1845,54 @@ func TestReevaluateClearsDockerContainerAlertWhenOverrideDisabled(t *testing.T)t.Fatalf("expected docker container alert to be cleared when override is disabled")}}++func TestReevaluateClearsDockerContainerAlertWhenIgnoredPrefixAdded(t *testing.T) {+ m := NewManager()++ resourceID := "docker:host-2/container-abc123"+ alertID := resourceID + "-cpu"++ resolved := make(chan string, 1)+ m.SetResolvedCallback(func(id string) {+ resolved <- id+ })++ m.mu.Lock()+ m.activeAlerts[alertID] = &Alert{+ ID: alertID,+ Type: "cpu",+ ResourceID: resourceID,+ ResourceName: "qbittorrentvpn",+ Instance: "Docker",+ Metadata: map[string]interface{}{+ "resourceType": "Docker Container",+ "containerId": "abc123",+ "containerName": "qbittorrentvpn",+ },+ Threshold: 80,+ Value: 95,+ }+ m.mu.Unlock()++ config := m.GetConfig()+ config.DockerIgnoredContainerPrefixes = []string{"qbit"}+ config.ActivationState = ActivationActive++ m.UpdateConfig(config)++ select {+ case got := <-resolved:+ if got != alertID {+ t.Fatalf("resolved callback fired for unexpected alert %s", got)+ }+ case <-time.After(200 * time.Millisecond):+ t.Fatalf("expected alert to be resolved after adding ignored prefix")+ }++ m.mu.RLock()+ _, exists := m.activeAlerts[alertID]+ m.mu.RUnlock()+ if exists {+ t.Fatalf("expected docker container alert to be cleared when ignored prefix is configured")+ }+}