diff --git a/public/app/plugins/panel/graph/alert_tab_ctrl.ts b/public/app/plugins/panel/graph/alert_tab_ctrl.ts
index c47d58631b8..2578f17ffca 100644
--- a/public/app/plugins/panel/graph/alert_tab_ctrl.ts
+++ b/public/app/plugins/panel/graph/alert_tab_ctrl.ts
@@ -62,8 +62,8 @@ export class AlertTabCtrl {
});
}
- getThresholdWithDefaults(thresholds, type) {
- var threshold = thresholds[type] || {};
+ getThresholdWithDefaults(threshold) {
+ threshold = threshold || {};
threshold.op = threshold.op || '>';
threshold.value = threshold.value || undefined;
return threshold;
@@ -73,13 +73,8 @@ export class AlertTabCtrl {
var alert = this.alert = this.panel.alert = this.panel.alert || {};
// set threshold defaults
- alert.thresholds = alert.thresholds || {};
- alert.thresholds.warn = this.getThresholdWithDefaults(alert.thresholds, 'warn');
- alert.thresholds.crit = this.getThresholdWithDefaults(alert.thresholds, 'crit');
-
- alert.frequency = alert.frequency || '60s';
- alert.handler = alert.handler || 1;
- alert.notifications = alert.notifications || [];
+ alert.warn = this.getThresholdWithDefaults(alert.warn);
+ alert.crit = this.getThresholdWithDefaults(alert.crit);
alert.query = alert.query || {};
alert.query.refId = alert.query.refId || 'A';
@@ -90,6 +85,10 @@ export class AlertTabCtrl {
alert.transform.type = alert.transform.type || 'aggregation';
alert.transform.method = alert.transform.method || 'avg';
+ alert.frequency = alert.frequency || '60s';
+ alert.handler = alert.handler || 1;
+ alert.notifications = alert.notifications || [];
+
var defaultName = this.panel.title + ' alert';
alert.name = alert.name || defaultName;
alert.description = alert.description || defaultName;
@@ -133,13 +132,11 @@ export class AlertTabCtrl {
}
delete() {
- // keep threshold object (instance used by graph handles)
- var thresholds = this.alert.thresholds;
- thresholds.warn.value = undefined;
- thresholds.crit.value = undefined;
+ this.alert.enabled = false;
+ this.alert.warn.value = undefined;
+ this.alert.crit.value = undefined;
// reset model but keep thresholds instance
- this.alert = this.panel.alert = {thresholds: thresholds};
this.initModel();
}
diff --git a/public/app/plugins/panel/graph/graph.js b/public/app/plugins/panel/graph/graph.js
index b76956ff6e8..6c59bd63cea 100755
--- a/public/app/plugins/panel/graph/graph.js
+++ b/public/app/plugins/panel/graph/graph.js
@@ -333,13 +333,12 @@ function (angular, $, moment, _, kbn, GraphTooltip, thresholds) {
}
function addGridThresholds(options, panel) {
- if (!panel.alert || !panel.alert.thresholds) {
+ if (!panel.alert) {
return;
}
- var thresholds = panel.alert.thresholds;
- var crit = thresholds.crit;
- var warn = thresholds.warn;
+ var crit = panel.alert.crit;
+ var warn = panel.alert.warn;
var critEdge = Infinity;
var warnEdge = crit.value;
diff --git a/public/app/plugins/panel/graph/partials/tab_alerting.html b/public/app/plugins/panel/graph/partials/tab_alerting.html
index c07886aeddf..3cbc6042a88 100644
--- a/public/app/plugins/panel/graph/partials/tab_alerting.html
+++ b/public/app/plugins/panel/graph/partials/tab_alerting.html
@@ -8,16 +8,16 @@
Critcal if
-