Skip to content

Commit

Permalink
problems: use event tags for problems instead of trigger tags, #487
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Feb 12, 2019
1 parent 496d4a8 commit 8809b5a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,20 @@ export class ZabbixAPIConnector {
});
}

getExtendedEventData(eventids) {
var params = {
output: 'extend',
eventids: eventids,
preservekeys: true,
select_acknowledges: 'extend',
selectTags: 'extend',
sortfield: 'clock',
sortorder: 'DESC'
};

return this.request('event.get', params);
}

getEventAlerts(eventids) {
const params = {
eventids: eventids,
Expand Down
5 changes: 3 additions & 2 deletions src/datasource-zabbix/zabbix/zabbix.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ZabbixNotImplemented } from './connectors/dbConnector';
const REQUESTS_TO_PROXYFY = [
'getHistory', 'getTrend', 'getGroups', 'getHosts', 'getApps', 'getItems', 'getMacros', 'getItemsByIDs',
'getEvents', 'getAlerts', 'getHostAlerts', 'getAcknowledges', 'getITService', 'getSLA', 'getVersion', 'getProxies',
'getEventAlerts'
'getEventAlerts', 'getExtendedEventData'
];

const REQUESTS_TO_CACHE = [
Expand All @@ -18,7 +18,8 @@ const REQUESTS_TO_CACHE = [

const REQUESTS_TO_BIND = [
'getHistory', 'getTrend', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts',
'getAcknowledges', 'getITService', 'getVersion', 'login', 'acknowledgeEvent', 'getProxies', 'getEventAlerts'
'getAcknowledges', 'getITService', 'getVersion', 'login', 'acknowledgeEvent', 'getProxies', 'getEventAlerts',
'getExtendedEventData'
];

export class Zabbix {
Expand Down
15 changes: 14 additions & 1 deletion src/panel-triggers/triggers_panel_ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,13 @@ export class TriggerPanelCtrl extends PanelCtrl {
return trigger.lastEvent.eventid;
}));
return Promise.all([
this.datasources[ds].zabbix.getAcknowledges(eventids),
this.datasources[ds].zabbix.getExtendedEventData(eventids),
this.datasources[ds].zabbix.getEventAlerts(eventids),
Promise.resolve(triggers)
]);
})
.then(([events, alerts, triggers]) => {
this.addEventTags(events, triggers);
this.addAcknowledges(events, triggers);
this.addEventAlerts(alerts, triggers);
return triggers;
Expand Down Expand Up @@ -323,6 +324,18 @@ export class TriggerPanelCtrl extends PanelCtrl {
return ack;
}

addEventTags(events, triggers) {
_.each(triggers, trigger => {
var event = _.find(events, event => {
return event.eventid === trigger.lastEvent.eventid;
});
if (event && event.tags && event.tags.length) {
trigger.tags = event.tags;
}
});
return triggers;
}

addEventAlerts(alerts, triggers) {
alerts.forEach(alert => {
const trigger = _.find(triggers, t => {
Expand Down

0 comments on commit 8809b5a

Please sign in to comment.