Fixed templated variables query.
This commit is contained in:
@@ -277,8 +277,6 @@ function (angular, _, dateMath, utils, metricFunctions) {
|
|||||||
* of metrics in "{metric1,metcic2,...,metricN}" format.
|
* of metrics in "{metric1,metcic2,...,metricN}" format.
|
||||||
*/
|
*/
|
||||||
this.metricFindQuery = function (query) {
|
this.metricFindQuery = function (query) {
|
||||||
var metrics;
|
|
||||||
|
|
||||||
// Split query. Query structure:
|
// Split query. Query structure:
|
||||||
// group.host.app.item
|
// group.host.app.item
|
||||||
var parts = [];
|
var parts = [];
|
||||||
@@ -296,31 +294,36 @@ function (angular, _, dateMath, utils, metricFunctions) {
|
|||||||
|
|
||||||
// Get items
|
// Get items
|
||||||
if (parts.length === 4) {
|
if (parts.length === 4) {
|
||||||
var items = this.queryProcessor.filterItems(template.host, template.app, true);
|
//var items = this.queryProcessor.filterItems(template.host, template.app, true);
|
||||||
metrics = _.map(items, formatMetric);
|
return this.queryProcessor.filterItems(template.host, template.app, true)
|
||||||
|
.then(function(items) {
|
||||||
|
return _.map(items, formatMetric);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Get applications
|
// Get applications
|
||||||
else if (parts.length === 3) {
|
else if (parts.length === 3) {
|
||||||
var apps = this.queryProcessor.filterApplications(template.host);
|
return this.queryProcessor.filterApplications(template.host)
|
||||||
metrics = _.map(apps, formatMetric);
|
.then(function(apps) {
|
||||||
|
return _.map(apps, formatMetric);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Get hosts
|
// Get hosts
|
||||||
else if (parts.length === 2) {
|
else if (parts.length === 2) {
|
||||||
var hosts = this.queryProcessor.filterHosts(template.group);
|
return this.queryProcessor.filterHosts(template.group)
|
||||||
metrics = _.map(hosts, formatMetric);
|
.then(function(hosts) {
|
||||||
|
return _.map(hosts, formatMetric);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Get groups
|
// Get groups
|
||||||
else if (parts.length === 1) {
|
else if (parts.length === 1) {
|
||||||
metrics = _.map(this.zabbixCache.getGroups(template.group), formatMetric);
|
return this.zabbixCache.getGroups(template.group).then(function(groups) {
|
||||||
|
return _.map(groups, formatMetric);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Return empty object for invalid request
|
// Return empty object for invalid request
|
||||||
else {
|
else {
|
||||||
var d = $q.defer();
|
return $q.when([]);
|
||||||
d.resolve([]);
|
|
||||||
return d.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $q.when(metrics);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function formatMetric(metricObj) {
|
function formatMetric(metricObj) {
|
||||||
|
|||||||
Reference in New Issue
Block a user