From 53ad2a07f5e5a3204ad46bc6137b54f1640dc190 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 4 Jun 2015 21:51:18 +0300 Subject: [PATCH] Some comments add for templated queries. --- zabbix/datasource.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index d572ef9..4885f91 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -408,10 +408,16 @@ function (angular, _, kbn) { }; - // For templated query + /** + * For templated query + * + * @param {string} query Query from Templating + * @return {string} Metric name - group, host, app or item or list + * of metrics in "{metric1,metcic2,...,metricN}" format. + */ ZabbixAPIDatasource.prototype.metricFindQuery = function (query) { // Split query. Query structure: - // group.host.app.key + // group.host.app.item var parts = []; _.each(query.split('.'), function (part) { part = templateSrv.replace(part); @@ -423,7 +429,7 @@ function (angular, _, kbn) { parts.push(part); } }); - var template = _.object(['group', 'host', 'app', 'key'], parts) + var template = _.object(['group', 'host', 'app', 'item'], parts) // Get items if (parts.length === 4) { @@ -480,6 +486,19 @@ function (angular, _, kbn) { }; + /** + * Find items from templated request + * + * @param {object} template Template object in format: + * { + * group: [groupnames], + * host: [hostnames], + * app: [appnames], + * item: [itemnames] + * } + * + * @return {Array} Array of Zabbix API item objects + */ ZabbixAPIDatasource.prototype.itemFindQuery = function(template) { var promises = [];