triggers: able to filter by proxy, #418

This commit is contained in:
Alexander Zobnin
2018-11-07 22:32:46 +03:00
parent f05bc08b88
commit 89a4364212
4 changed files with 64 additions and 26 deletions

View File

@@ -2,7 +2,7 @@ import _ from 'lodash';
import {DEFAULT_TARGET} from './triggers_panel_ctrl';
// Actual schema version
export const CURRENT_SCHEMA_VERSION = 4;
export const CURRENT_SCHEMA_VERSION = 5;
export function migratePanelSchema(panel) {
if (isEmptyPanel(panel)) {
@@ -31,7 +31,7 @@ export function migratePanelSchema(panel) {
delete panel.hideHostsInMaintenance;
}
if (schemaVersion < 4) {
if (schemaVersion < 5) {
if (panel.targets && !_.isEmpty(panel.targets)) {
_.each(panel.targets, (target) => {
_.defaultsDeep(target, DEFAULT_TARGET);

View File

@@ -19,7 +19,7 @@
<div class="section gf-form-group">
<h5 class="section-heading">{{ ds }}</h5>
<div class="gf-form-inline">
<div class="gf-form max-width-20">
<div class="gf-form">
<label class="gf-form-label query-keyword width-7">Group</label>
<input type="text"
ng-model="ctrl.panel.targets[ds].group.filter"
@@ -27,7 +27,7 @@
ng-blur="editor.parseTarget()"
data-min-length=0
data-items=100
class="gf-form-input"
class="gf-form-input width-14"
ng-class="{
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].group.filter),
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].group.filter)
@@ -41,16 +41,30 @@
ng-blur="editor.parseTarget()"
data-min-length=0
data-items=100
class="gf-form-input"
class="gf-form-input width-14"
ng-class="{
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].host.filter),
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].host.filter)
}">
</div>
<div class="gf-form">
<label class="gf-form-label query-keyword width-7">Proxy</label>
<input type="text"
ng-model="ctrl.panel.targets[ds].proxy.filter"
bs-typeahead="editor.getHostNames[ds]"
ng-blur="editor.parseTarget()"
data-min-length=0
data-items=100
class="gf-form-input width-14"
ng-class="{
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].proxy.filter),
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].proxy.filter)
}">
</div>
</div>
<div class="gf-form-inline">
<div class="gf-form max-width-20">
<div class="gf-form">
<label class="gf-form-label query-keyword width-7">Application</label>
<input type="text"
ng-model="ctrl.panel.targets[ds].application.filter"
@@ -58,7 +72,7 @@
ng-blur="editor.parseTarget()"
data-min-length=0
data-items=100
class="gf-form-input"
class="gf-form-input width-14"
ng-class="{
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].application.filter),
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].application.filter)
@@ -70,7 +84,7 @@
ng-model="ctrl.panel.targets[ds].trigger.filter"
ng-blur="editor.parseTarget()"
placeholder="trigger name"
class="gf-form-input"
class="gf-form-input width-14"
ng-style="ctrl.panel.targets[ds].trigger.style"
ng-class="{
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].trigger.filter),
@@ -80,7 +94,7 @@
</div>
<div class="gf-form">
<label class="gf-form-label query-keyword width-7">Tags</label>
<input type="text" class="gf-form-input"
<input type="text" class="gf-form-input width-14"
ng-model="ctrl.panel.targets[ds].tags.filter"
ng-blur="editor.parseTarget()"
placeholder="tag1:value1, tag2:value2">

View File

@@ -15,6 +15,7 @@ export const DEFAULT_TARGET = {
application: {filter: ""},
trigger: {filter: ""},
tags: {filter: ""},
proxy: {filter: ""},
};
export const DEFAULT_SEVERITY = [
@@ -204,7 +205,7 @@ export class TriggerPanelCtrl extends PanelCtrl {
getTriggers() {
let promises = _.map(this.panel.datasources, (ds) => {
let proxies = [];
let proxies;
return this.datasourceSrv.get(ds)
.then(datasource => {
const zabbix = datasource.zabbix;
@@ -217,27 +218,24 @@ export class TriggerPanelCtrl extends PanelCtrl {
const groupFilter = datasource.replaceTemplateVars(triggerFilter.group.filter);
const hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);
const appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);
const proxyFilter = datasource.replaceTemplateVars(triggerFilter.proxy.filter);
let triggersOptions = {
showTriggers: showEvents
};
return Promise.all([
zabbix.getTriggers(groupFilter, hostFilter, appFilter, triggersOptions),
zabbix.getTriggers(groupFilter, hostFilter, appFilter, triggersOptions, proxyFilter),
getProxiesPromise
]);
}).then(([triggers, sourceProxies]) => {
proxies = _.keyBy(sourceProxies, 'proxyid');
return this.getAcknowledges(triggers, ds);
}).then((triggers) => {
return this.setMaintenanceStatus(triggers);
}).then((triggers) => {
return this.filterTriggersPre(triggers, ds);
}).then((triggers) => {
return this.addTriggerDataSource(triggers, ds);
}).then((triggers) => {
return this.addTriggerHostProxy(triggers, proxies);
});
})
.then(triggers => this.setMaintenanceStatus(triggers))
.then(triggers => this.filterTriggersPre(triggers, ds))
.then(triggers => this.addTriggerDataSource(triggers, ds))
.then(triggers => this.addTriggerHostProxy(triggers, proxies));
});
return Promise.all(promises)