Просмотр исходного кода

feat(alerting): add warn/crit filter

bergquist 9 лет назад
Родитель
Сommit
7952723b71

+ 2 - 2
pkg/services/alerting/notifier.go

@@ -151,8 +151,8 @@ func NewNotificationFromDBModel(model *m.AlertNotification) (*Notification, erro
 		Name:         model.Name,
 		Type:         model.Type,
 		Notifierr:    notifier,
-		SendCritical: !model.Settings.Get("ignoreCrit").MustBool(),
-		SendWarning:  !model.Settings.Get("ignoreWarn").MustBool(),
+		SendCritical: model.Settings.Get("sendCrit").MustBool(),
+		SendWarning:  model.Settings.Get("sendWarn").MustBool(),
 	}, nil
 }
 

+ 7 - 0
public/app/features/alerting/notification_edit_ctrl.ts

@@ -13,6 +13,13 @@ export class AlertNotificationEditCtrl {
   constructor(private $routeParams, private backendSrv, private $scope) {
     if ($routeParams.notificationId) {
       this.loadNotification($routeParams.notificationId);
+    } else {
+      this.notification = {
+        settings: {
+          sendCrit: true,
+          sendWarn: true,
+        }
+      };
     }
   }
 

+ 6 - 0
public/app/features/alerting/partials/notification_edit.html

@@ -24,6 +24,12 @@
 		<div class="gf-form">
 			<gf-form-switch class="gf-form" label-class="width-8" label="Always execute" checked="ctrl.notification.alwaysExecute" on-change=""></gf-form-switch>
 		</div>
+		<div class="gf-form">
+			<gf-form-switch class="gf-form" label-class="width-8" label="Send Warning" checked="ctrl.notification.settings.sendWarn" on-change=""></gf-form-switch>
+		</div>
+		<div class="gf-form">
+			<gf-form-switch class="gf-form" label-class="width-8" label="Send Critical" checked="ctrl.notification.settings.sendCrit" on-change=""></gf-form-switch>
+		</div>
 	</div>
 	<div class="gf-form-group section" ng-show="ctrl.notification.type === 'webhook'">
 		<div class="gf-form">