|
|
@@ -8,9 +8,10 @@ export class AlertTabCtrl {
|
|
|
panel: any;
|
|
|
panelCtrl: any;
|
|
|
alerting: any;
|
|
|
+ metricTargets = [{ refId: '- select query -' } ];
|
|
|
|
|
|
/** @ngInject */
|
|
|
- constructor($scope) {
|
|
|
+ constructor($scope, private $timeout) {
|
|
|
$scope.alertTab = this; //HACK ATTACK!
|
|
|
this.panelCtrl = $scope.ctrl;
|
|
|
this.panel = this.panelCtrl.panel;
|
|
|
@@ -18,18 +19,26 @@ export class AlertTabCtrl {
|
|
|
this.panel.alerting.aggregator = this.panel.alerting.aggregator || 'avg';
|
|
|
this.panel.alerting.interval = this.panel.alerting.interval || '60s';
|
|
|
this.panel.alerting.queryRange = this.panel.alerting.queryRange || '10m';
|
|
|
+ this.panel.alerting.warnOperator = this.panel.alerting.warnOperator || '>';
|
|
|
+ this.panel.alerting.critOperator = this.panel.alerting.critOperator || '>';
|
|
|
+ this.panel.alerting.title = this.panel.alerting.title || this.panel.title + ' alert';
|
|
|
+
|
|
|
+ this.panel.targets.map(target => {
|
|
|
+ this.metricTargets.push(target);
|
|
|
+ });
|
|
|
+ this.panel.alerting.queryRef = this.panel.alerting.queryRef || this.metricTargets[0].refId;
|
|
|
|
|
|
this.convertThresholdsToAlertThresholds();
|
|
|
}
|
|
|
|
|
|
convertThresholdsToAlertThresholds() {
|
|
|
if (this.panel.grid && this.panel.grid.threshold1) {
|
|
|
- this.panel.alerting.warnOperator = '<';
|
|
|
+ this.panel.alerting.warnOperator = '>';
|
|
|
this.panel.alerting.warnLevel = this.panel.grid.threshold1;
|
|
|
}
|
|
|
|
|
|
if (this.panel.grid && this.panel.grid.threshold2) {
|
|
|
- this.panel.alerting.critOperator = '<';
|
|
|
+ this.panel.alerting.critOperator = '>';
|
|
|
this.panel.alerting.critLevel = this.panel.grid.threshold2;
|
|
|
}
|
|
|
}
|