Add Min severity option to datasource config.

This commit is contained in:
Alexander Zobnin
2017-03-08 16:27:15 +03:00
parent c43bd8bf33
commit abf979de4b
6 changed files with 38 additions and 1 deletions

View File

@@ -223,6 +223,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
// Alerting options
this.alertingEnabled = instanceSettings.jsonData.alerting;
this.addThresholds = instanceSettings.jsonData.addThresholds;
this.alertingMinSeverity = instanceSettings.jsonData.alertingMinSeverity || 2;
this.zabbix = new Zabbix(this.url, this.username, this.password, this.basicAuth, this.withCredentials, this.cacheTTL);
@@ -609,6 +610,10 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
return _this7.zabbix.getAlerts(itemids);
}).then(function (triggers) {
triggers = _.filter(triggers, function (trigger) {
return trigger.priority >= _this7.alertingMinSeverity;
});
if (!triggers || triggers.length === 0) {
return {};
}

File diff suppressed because one or more lines are too long

View File

@@ -70,4 +70,15 @@
label="Add thresholds"
checked="ctrl.current.jsonData.addThresholds">
</gf-form-switch>
<div class="gf-form max-width-20">
<span class="gf-form-label width-8">Min severity</span>
<div class="gf-form-select-wrapper max-width-16">
<select class="gf-form-input" ng-model="ctrl.current.jsonData.alertingMinSeverity"
ng-options="s.val as s.text for s in [
{val: 0, text: 'Not classified'}, {val: 1, text:'Information'},
{val: 2, text: 'Warning'}, {val: 3, text: 'Average'},
{val: 4, text: 'High'}, {val: 5, text: 'Disaster'}]">
</select>
</div>
</div>
</div>

View File

@@ -81,6 +81,7 @@ var ZabbixAPIDatasource = function () {
// Alerting options
this.alertingEnabled = instanceSettings.jsonData.alerting;
this.addThresholds = instanceSettings.jsonData.addThresholds;
this.alertingMinSeverity = instanceSettings.jsonData.alertingMinSeverity || 2;
this.zabbix = new Zabbix(this.url, this.username, this.password, this.basicAuth, this.withCredentials, this.cacheTTL);
@@ -498,6 +499,10 @@ var ZabbixAPIDatasource = function () {
return _this7.zabbix.getAlerts(itemids);
}).then(function (triggers) {
triggers = _lodash2.default.filter(triggers, function (trigger) {
return trigger.priority >= _this7.alertingMinSeverity;
});
if (!triggers || triggers.length === 0) {
return {};
}