Add tags filter to triggers query
This commit is contained in:
@@ -542,6 +542,19 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
|
||||
const hostids = hosts?.map((h) => h.hostid);
|
||||
const appids = apps?.map((a) => a.applicationid);
|
||||
const options = getTriggersOptions(target, timeRange);
|
||||
|
||||
const tagsFilter = this.replaceTemplateVars(target.tags?.filter, request.scopedVars);
|
||||
// replaceTemplateVars() builds regex-like string, so we should trim it.
|
||||
const tagsFilterStr = tagsFilter.replace('/^', '').replace('$/', '');
|
||||
const tags = utils.parseTags(tagsFilterStr);
|
||||
tags.forEach((tag) => {
|
||||
// Zabbix uses {"tag": "<tag>", "value": "<value>", "operator": "<operator>"} format, where 1 means Equal
|
||||
tag.operator = 1;
|
||||
});
|
||||
if (tags && tags.length) {
|
||||
options.tags = tags;
|
||||
}
|
||||
|
||||
const alerts = await this.zabbix.getHostAlerts(hostids, appids, options);
|
||||
return responseHandler.handleTriggersResponse(alerts, groups, timeRange, target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user