mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
Merge pull request #42768 from s0nea/wip-dashboard-suppressed-alerts
mgr/dashboard: don't notify for suppressed alerts
This commit is contained in:
commit
6d7dfefafb
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user