]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/services/prometheus-notification.service.ts
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / services / prometheus-notification.service.ts
index 5b4f795bb5f5f80ba22c116905bb8df68be14403..d2b35b2599bd0c9058f3b6e0d30b665cf3b8d5d8 100644 (file)
@@ -4,14 +4,15 @@ import * as _ from 'lodash';
 
 import { PrometheusService } from '../api/prometheus.service';
 import { CdNotificationConfig } from '../models/cd-notification';
-import { PrometheusNotification } from '../models/prometheus-alerts';
+import { AlertmanagerNotification } from '../models/prometheus-alerts';
 import { PrometheusAlertFormatter } from './prometheus-alert-formatter';
 
 @Injectable({
   providedIn: 'root'
 })
 export class PrometheusNotificationService {
-  private notifications: PrometheusNotification[];
+  private notifications: AlertmanagerNotification[];
+  private backendFailure = false;
 
   constructor(
     private alertFormatter: PrometheusAlertFormatter,
@@ -21,12 +22,18 @@ export class PrometheusNotificationService {
   }
 
   refresh() {
+    if (this.backendFailure) {
+      return;
+    }
     this.prometheusService
       .getNotifications(_.last(this.notifications))
-      .subscribe((notifications) => this.handleNotifications(notifications));
+      .subscribe(
+        (notifications) => this.handleNotifications(notifications),
+        () => (this.backendFailure = true)
+      );
   }
 
-  private handleNotifications(notifications: PrometheusNotification[]) {
+  private handleNotifications(notifications: AlertmanagerNotification[]) {
     if (notifications.length === 0) {
       return;
     }
@@ -38,7 +45,7 @@ export class PrometheusNotificationService {
     this.notifications = this.notifications.concat(notifications);
   }
 
-  private formatNotification(notification: PrometheusNotification): CdNotificationConfig[] {
+  private formatNotification(notification: AlertmanagerNotification): CdNotificationConfig[] {
     return this.alertFormatter
       .convertToCustomAlerts(notification.alerts)
       .map((alert) => this.alertFormatter.convertAlertToNotification(alert));