Improved annotations fetching (use dashboard time interval for triggers getting).

This commit is contained in:
Alexander Zobnin
2016-04-01 12:35:39 +03:00
parent f922c2fe6f
commit 1b7abd5d37
2 changed files with 11 additions and 5 deletions

View File

@@ -337,8 +337,8 @@ export class ZabbixAPIDatasource {
///////////////// /////////////////
annotationQuery(options) { annotationQuery(options) {
var from = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000); var timeFrom = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000);
var to = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000); var timeTo = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000);
var annotation = options.annotation; var annotation = options.annotation;
var self = this; var self = this;
var showOkEvents = annotation.showOkEvents ? [0, 1] : 1; var showOkEvents = annotation.showOkEvents ? [0, 1] : 1;
@@ -353,7 +353,8 @@ export class ZabbixAPIDatasource {
return self.zabbixAPI.getTriggers(query.groupids, return self.zabbixAPI.getTriggers(query.groupids,
query.hostids, query.hostids,
query.applicationids, query.applicationids,
showTriggers) showTriggers,
timeFrom, timeTo)
.then(function(triggers) { .then(function(triggers) {
// Filter triggers by description // Filter triggers by description
@@ -373,7 +374,7 @@ export class ZabbixAPIDatasource {
}); });
var objectids = _.map(triggers, 'triggerid'); var objectids = _.map(triggers, 'triggerid');
return self.zabbixAPI.getEvents(objectids, from, to, showOkEvents) return self.zabbixAPI.getEvents(objectids, timeFrom, timeTo, showOkEvents)
.then(function (events) { .then(function (events) {
var indexedTriggers = _.indexBy(triggers, 'triggerid'); var indexedTriggers = _.indexBy(triggers, 'triggerid');

View File

@@ -298,7 +298,7 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
return this.request('service.getsla', params); return this.request('service.getsla', params);
} }
getTriggers(groupids, hostids, applicationids, showTriggers) { getTriggers(groupids, hostids, applicationids, showTriggers, timeFrom, timeTo) {
var params = { var params = {
output: 'extend', output: 'extend',
groupids: groupids, groupids: groupids,
@@ -322,6 +322,11 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
params.filter.value = showTriggers; params.filter.value = showTriggers;
} }
if (timeFrom || timeTo) {
params.lastChangeSince = timeFrom;
params.lastChangeTill = timeTo;
}
return this.request('trigger.get', params); return this.request('trigger.get', params);
} }