Problems: add min severity filter

This commit is contained in:
Alexander Zobnin
2020-05-15 19:05:07 +03:00
parent b94a6c4841
commit 5034c2ca90
5 changed files with 25 additions and 2 deletions

View File

@@ -414,9 +414,15 @@ export class ZabbixDatasource {
const problemsOptions: any = { const problemsOptions: any = {
recent: showProblems === ShowProblemTypes.Recent, recent: showProblems === ShowProblemTypes.Recent,
minSeverity: target.options?.minSeverity,
limit: target.options?.limit, limit: target.options?.limit,
}; };
if (target.options?.minSeverity) {
const severities = [0, 1, 2, 3, 4, 5].filter(v => v >= target.options?.minSeverity);
problemsOptions.severities = severities;
}
if (showProblems !== ShowProblemTypes.Problems) { if (showProblems !== ShowProblemTypes.Problems) {
problemsOptions.timeFrom = timeFrom; problemsOptions.timeFrom = timeFrom;
problemsOptions.timeTo = timeTo; problemsOptions.timeTo = timeTo;

View File

@@ -178,13 +178,23 @@
</select> </select>
</div> </div>
</div> </div>
<div class="gf-form max-width-20" ng-show="ctrl.target.queryType == editorMode.PROBLEMS">
<label class="gf-form-label query-keyword width-7">Min severity</label>
<div class="gf-form-select-wrapper max-width-20">
<select class="gf-form-input"
ng-model="ctrl.target.options.minSeverity"
ng-options="v.val as v.text for v in ctrl.severityOptions"
ng-change="ctrl.onTargetBlur()">
</select>
</div>
</div>
<div class="gf-form max-width-20" ng-show="ctrl.target.queryType == editorMode.TRIGGERS"> <div class="gf-form max-width-20" ng-show="ctrl.target.queryType == editorMode.TRIGGERS">
<label class="gf-form-label query-keyword width-7">Min Severity</label> <label class="gf-form-label query-keyword width-7">Min Severity</label>
<div class="gf-form-select-wrapper width-14"> <div class="gf-form-select-wrapper width-14">
<select class="gf-form-input" <select class="gf-form-input"
ng-change="ctrl.onTargetBlur()" ng-change="ctrl.onTargetBlur()"
ng-model="ctrl.target.triggers.minSeverity" ng-model="ctrl.target.triggers.minSeverity"
ng-options="s.val as s.text for s in ctrl.triggerSeverity"> ng-options="s.val as s.text for s in ctrl.severityOptions">
</select> </select>
</div> </div>
</div> </div>

View File

@@ -42,6 +42,7 @@ function getProblemsTargetDefaults() {
return { return {
showProblems: ShowProblemTypes.Problems, showProblems: ShowProblemTypes.Problems,
options: { options: {
minSeverity: 0,
sortProblems: 'default', sortProblems: 'default',
acknowledged: 2, acknowledged: 2,
hostsInMaintenance: false, hostsInMaintenance: false,
@@ -51,6 +52,10 @@ function getProblemsTargetDefaults() {
}; };
} }
function getSeverityOptions() {
return c.TRIGGER_SEVERITY;
}
export class ZabbixQueryController extends QueryCtrl { export class ZabbixQueryController extends QueryCtrl {
/** @ngInject */ /** @ngInject */
@@ -120,7 +125,7 @@ export class ZabbixQueryController extends QueryCtrl {
this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }]; this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }];
this.triggerSeverity = c.TRIGGER_SEVERITY; this.severityOptions = getSeverityOptions();
// Map functions for bs-typeahead // Map functions for bs-typeahead
this.getGroupNames = _.bind(this.getMetricNames, this, 'groupList'); this.getGroupNames = _.bind(this.getMetricNames, this, 'groupList');

View File

@@ -132,6 +132,7 @@ function migrateOptions(panel) {
return { return {
hostsInMaintenance: panel.hostsInMaintenance, hostsInMaintenance: panel.hostsInMaintenance,
sortProblems: panel.sortTriggersBy?.value === 'priority' ? 'priority' : 'default', sortProblems: panel.sortTriggersBy?.value === 'priority' ? 'priority' : 'default',
minSeverity: 0,
acknowledged: acknowledged, acknowledged: acknowledged,
limit: limit, limit: limit,
}; };

View File

@@ -67,6 +67,7 @@ describe('Triggers Panel schema migration', () => {
hostsInMaintenance: false, hostsInMaintenance: false,
acknowledged: 0, acknowledged: 0,
sortProblems: 'default', sortProblems: 'default',
minSeverity: 0,
limit: 10, limit: 10,
}, },
} }