Problems: add min severity filter
This commit is contained in:
@@ -414,9 +414,15 @@ export class ZabbixDatasource {
|
||||
|
||||
const problemsOptions: any = {
|
||||
recent: showProblems === ShowProblemTypes.Recent,
|
||||
minSeverity: target.options?.minSeverity,
|
||||
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) {
|
||||
problemsOptions.timeFrom = timeFrom;
|
||||
problemsOptions.timeTo = timeTo;
|
||||
|
||||
@@ -178,13 +178,23 @@
|
||||
</select>
|
||||
</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">
|
||||
<label class="gf-form-label query-keyword width-7">Min Severity</label>
|
||||
<div class="gf-form-select-wrapper width-14">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,6 +42,7 @@ function getProblemsTargetDefaults() {
|
||||
return {
|
||||
showProblems: ShowProblemTypes.Problems,
|
||||
options: {
|
||||
minSeverity: 0,
|
||||
sortProblems: 'default',
|
||||
acknowledged: 2,
|
||||
hostsInMaintenance: false,
|
||||
@@ -51,6 +52,10 @@ function getProblemsTargetDefaults() {
|
||||
};
|
||||
}
|
||||
|
||||
function getSeverityOptions() {
|
||||
return c.TRIGGER_SEVERITY;
|
||||
}
|
||||
|
||||
export class ZabbixQueryController extends QueryCtrl {
|
||||
|
||||
/** @ngInject */
|
||||
@@ -120,7 +125,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
|
||||
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
|
||||
this.getGroupNames = _.bind(this.getMetricNames, this, 'groupList');
|
||||
|
||||
@@ -132,6 +132,7 @@ function migrateOptions(panel) {
|
||||
return {
|
||||
hostsInMaintenance: panel.hostsInMaintenance,
|
||||
sortProblems: panel.sortTriggersBy?.value === 'priority' ? 'priority' : 'default',
|
||||
minSeverity: 0,
|
||||
acknowledged: acknowledged,
|
||||
limit: limit,
|
||||
};
|
||||
|
||||
@@ -67,6 +67,7 @@ describe('Triggers Panel schema migration', () => {
|
||||
hostsInMaintenance: false,
|
||||
acknowledged: 0,
|
||||
sortProblems: 'default',
|
||||
minSeverity: 0,
|
||||
limit: 10,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user