From 8809b5a9d3e6e4f20c0a583745eb70021d14955c Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 11 Feb 2019 17:30:38 +0300 Subject: [PATCH] problems: use event tags for problems instead of trigger tags, #487 --- .../connectors/zabbix_api/zabbixAPIConnector.js | 14 ++++++++++++++ src/datasource-zabbix/zabbix/zabbix.js | 5 +++-- src/panel-triggers/triggers_panel_ctrl.js | 15 ++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js index 02b18f63b..8b12c9694 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js @@ -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, diff --git a/src/datasource-zabbix/zabbix/zabbix.js b/src/datasource-zabbix/zabbix/zabbix.js index ead008718..b6cb66bbb 100644 --- a/src/datasource-zabbix/zabbix/zabbix.js +++ b/src/datasource-zabbix/zabbix/zabbix.js @@ -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 = [ @@ -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 { diff --git a/src/panel-triggers/triggers_panel_ctrl.js b/src/panel-triggers/triggers_panel_ctrl.js index 493bd552f..068a51daa 100644 --- a/src/panel-triggers/triggers_panel_ctrl.js +++ b/src/panel-triggers/triggers_panel_ctrl.js @@ -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; @@ -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 => {