]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: don't notify for suppressed alerts 42974/head
authorTatjana Dehler <tdehler@suse.com>
Thu, 12 Aug 2021 14:06:44 +0000 (16:06 +0200)
committerTatjana Dehler <tdehler@suse.com>
Mon, 30 Aug 2021 13:22:24 +0000 (15:22 +0200)
Fixes: https://tracker.ceph.com/issues/51987
Signed-off-by: Tatjana Dehler <tdehler@suse.com>
(cherry picked from commit e9f316d678dd24e25e82474da95dbfbb72d763b5)

src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-alert.service.ts

index d16d0c85d88ae88e6eca70a515ccc02a23d4e6ca..aa3160b304cca1a875f35c3a128e922a46d8b19d 100644 (file)
@@ -131,19 +131,25 @@ describe('PrometheusAlertService', () => {
     });
 
     it('should notify on alert change', () => {
-      alerts = [prometheus.createAlert('alert0', 'suppressed')];
+      alerts = [prometheus.createAlert('alert0', 'resolved')];
       service.refresh();
       expect(notificationService.show).toHaveBeenCalledWith(
         new CdNotificationConfig(
-          NotificationType.info,
-          'alert0 (suppressed)',
-          'alert0 is suppressed ' + prometheus.createLink('http://alert0'),
+          NotificationType.success,
+          'alert0 (resolved)',
+          'alert0 is resolved ' + prometheus.createLink('http://alert0'),
           undefined,
           'Prometheus'
         )
       );
     });
 
+    it('should not notify on change to suppressed', () => {
+      alerts = [prometheus.createAlert('alert0', 'suppressed')];
+      service.refresh();
+      expect(notificationService.show).not.toHaveBeenCalled();
+    });
+
     it('should notify on a new alert', () => {
       alerts = [prometheus.createAlert('alert1'), prometheus.createAlert('alert0')];
       service.refresh();
index 6acd244617e1843223cb4debc6e0bbda90f7dfe1..6223808fb0122e3bd5cd3a3a62c1580a138fd8d0 100644 (file)
@@ -75,7 +75,10 @@ export class PrometheusAlertService {
       this.alertFormatter.convertToCustomAlerts(alerts),
       this.alertFormatter.convertToCustomAlerts(oldAlerts)
     );
-    const notifications = changedAlerts.map((alert) =>
+    const suppressedFiltered = _.filter(changedAlerts, (alert) => {
+      return alert.status !== 'suppressed';
+    });
+    const notifications = suppressedFiltered.map((alert) =>
       this.alertFormatter.convertAlertToNotification(alert)
     );
     this.alertFormatter.sendNotifications(notifications);