Merge pull request #10 from ishanbha/AMBARI-24898-master
[AMBARI-24898] Add cluster drop down to Grafana aggregate dashboards.
diff --git a/ambari-metrics-grafana/ambari-metrics/datasource.js b/ambari-metrics-grafana/ambari-metrics/datasource.js
index 6e14f33..c6885da 100644
--- a/ambari-metrics-grafana/ambari-metrics/datasource.js
+++ b/ambari-metrics-grafana/ambari-metrics/datasource.js
@@ -689,14 +689,9 @@
});
}
// To speed up querying on templatized dashboards.
- var indexOfHosts = -1;
- for (var i = 0; i < templateSrv.variables.length; i++) {
- if (templateSrv.variables[i].name == 'hosts' && templateSrv.index.hosts) {
- indexOfHosts = i;
- }
- }
- if (indexOfHosts >= 0) {
- let allHosts = [];
+ let allHosts;
+ if (templateSrv.index.hosts) {
+ allHosts = [];
const hosts = templateSrv.index.hosts.options
for (let host of hosts) {
if (host.text.toLowerCase() === "all" && host.selected) {
@@ -705,13 +700,13 @@
} else if (host.selected) {
allHosts.push(host.text);
}
- };
- metricsPromises.push(_.map(options.targets, function (target) {
- target.templatedHost = allHosts ? allHosts : '';
- target.templatedCluster = templatedCluster;
- return getAllHostData(target);
- }));
+ }
}
+ metricsPromises.push(_.map(options.targets, function (target) {
+ target.templatedHost = allHosts ? allHosts : '';
+ target.templatedCluster = templatedCluster;
+ return getAllHostData(target);
+ }));
metricsPromises = _.flatten(metricsPromises);
} else {
// Non Templatized Dashboards