support template variables in itemid query mode

This commit is contained in:
Alexander Zobnin
2017-07-25 18:54:30 +03:00
parent fc1748a087
commit 3b1bc4d4a5
4 changed files with 25 additions and 1 deletions

View File

@@ -356,6 +356,7 @@ var ZabbixAPIDatasource = function () {
var _this5 = this;
var itemids = target.itemids;
itemids = this.templateSrv.replace(itemids, options.scopedVars, zabbixItemIdsTemplateFormat);
itemids = _lodash2.default.map(itemids.split(','), function (itemid) {
return itemid.trim();
});
@@ -741,6 +742,13 @@ function zabbixTemplateFormat(value) {
return '(' + escapedValues.join('|') + ')';
}
function zabbixItemIdsTemplateFormat(value) {
if (typeof value === 'string') {
return value;
}
return value.join(',');
}
/**
* If template variables are used in request, replace it using regex format
* and wrap with '/' for proper multi-value work. Example: