AMBARI-21640 : Certain templated Grafana dashboards not showing data. (avijayan)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/07d6ec30
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/07d6ec30
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/07d6ec30

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: 07d6ec308dd2d54c0af720a181759391ffc22192
Parents: 4a122a2
Author: Aravindan Vijayan <avija...@hortonworks.com>
Authored: Thu Aug 3 09:40:40 2017 -0700
Committer: Aravindan Vijayan <avija...@hortonworks.com>
Committed: Thu Aug 3 09:40:48 2017 -0700

----------------------------------------------------------------------
 .../ambari-metrics/datasource.js                | 35 ++++++++++++++------
 .../HDF/grafana-nifi-hosts.json                 | 17 +++++++++-
 2 files changed, 41 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/07d6ec30/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js 
b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js
index b4a339e..07e76af 100644
--- a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js
+++ b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js
@@ -216,11 +216,12 @@ define([
           var getHostAppIdData = function(target) {
             var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision=' 
             + target.precision;
+            var instanceId = typeof target.cluster == 'undefined'  ? '' : 
'&instanceId=' + target.cluster;
             var metricAggregator = target.aggregator === "none" ? '' : '._' + 
target.aggregator;
             var metricTransform = !target.transform || target.transform === 
"none" ? '' : '._' + target.transform;
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
             return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.metric + metricTransform +
-            metricAggregator + "&hostname=" + target.hosts + '&appId=' + 
target.app + '&instanceId=' + target.cluster + '&startTime=' + from +
+            metricAggregator + "&hostname=" + target.hosts + '&appId=' + 
target.app + instanceId + '&startTime=' + from +
             '&endTime=' + to + precision + seriesAggregator }).then(
               getMetricsData(target)
             );
@@ -240,6 +241,7 @@ define([
 
           var getServiceAppIdData = function(target) {
             var tCluster = (_.isEmpty(templateSrv.variables))? 
templatedCluster : '';
+            var instanceId = typeof tCluster == 'undefined'  ? '' : 
'&instanceId=' + tCluster;
             var tHost = (_.isEmpty(templateSrv.variables)) ? templatedHost : 
target.templatedHost;
             var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
             + target.precision;
@@ -247,13 +249,14 @@ define([
             var metricTransform = !target.transform || target.transform === 
"none" ? '' : '._' + target.transform;
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
             return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.metric + metricTransform
-              + metricAggregator + '&hostname=' + tHost + '&appId=' + 
target.app + '&instanceId=' + tCluster + '&startTime=' + from +
+              + metricAggregator + '&hostname=' + tHost + '&appId=' + 
target.app + instanceId + '&startTime=' + from +
               '&endTime=' + to + precision + seriesAggregator }).then(
               getMetricsData(target)
             );
           };
           // To speed up querying on templatized dashboards.
           var getAllHostData = function(target) {
+            var instanceId = typeof target.templatedCluster == 'undefined'  ? 
'' : '&instanceId=' + target.templatedCluster;
             var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
             + target.precision;
             var metricAggregator = target.aggregator === "none" ? '' : '._' + 
target.aggregator;
@@ -269,7 +272,7 @@ define([
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
             var templatedComponent = (_.isEmpty(tComponent)) ? target.app : 
tComponent;
             return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.metric + metricTransform
-              + metricAggregator + '&hostname=' + target.templatedHost + 
'&appId=' + templatedComponent + '&instanceId=' + target.templatedCluster
+              + metricAggregator + '&hostname=' + target.templatedHost + 
'&appId=' + templatedComponent + instanceId
               + '&startTime=' + from + '&endTime=' + to + precision + topN + 
seriesAggregator }).then(
               allHostMetricsData(target)
             );
@@ -288,10 +291,11 @@ define([
             );
           };
           var getHbaseAppIdData = function(target) {
-            var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
+              var instanceId = typeof target.templatedCluster == 'undefined'  
? '' : '&instanceId=' + target.templatedCluster;
+              var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
             + target.precision;
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
-            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.hbMetric + + '&instanceId=' + 
target.templatedCluster + '&appId=hbase&startTime='
+            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.hbMetric + instanceId + 
'&appId=hbase&startTime='
             + from + '&endTime=' + to + precision + seriesAggregator }).then(
               allHostMetricsData(target)
             );
@@ -300,22 +304,25 @@ define([
           var getKafkaAppIdData = function(target) {
             var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
             + target.precision;
+            var instanceId = typeof target.templatedCluster == 'undefined'  ? 
'' : '&instanceId=' + target.templatedCluster;
             var metricAggregator = target.aggregator === "none" ? '' : '._' + 
target.aggregator;
             var metricTransform = !target.transform || target.transform === 
"none" ? '' : '._' + target.transform;
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
-            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.kbMetric + metricTransform + + 
'&instanceId=' + target.templatedCluster
+            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.kbMetric + metricTransform + 
instanceId
               + metricAggregator + '&appId=kafka_broker&startTime=' + from +
               '&endTime=' + to + precision + seriesAggregator }).then(
               getMetricsData(target)
             );
           };
           var getNnAppIdData = function(target) {
+
             var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
             + target.precision;
+            var instanceId = typeof target.templatedCluster == 'undefined'  ? 
'' : '&instanceId=' + target.templatedCluster;
             var metricAggregator = target.aggregator === "none" ? '' : '._' + 
target.aggregator;
             var metricTransform = !target.transform || target.transform === 
"none" ? '' : '._' + target.transform;
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
-            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.nnMetric + metricTransform + 
'&instanceId=' + target.templatedCluster
+            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.nnMetric + metricTransform + 
instanceId
             + metricAggregator + '&appId=namenode&startTime=' + from + 
'&endTime=' + to + precision + seriesAggregator }).then(
               allHostMetricsData(target)
             );
@@ -323,12 +330,13 @@ define([
 
           // Storm Topology calls.
           var getStormData = function(target) {
+            var instanceId = typeof target.templatedCluster == 'undefined'  ? 
'' : '&instanceId=' + target.templatedCluster;
             var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
             + target.precision;
             var metricAggregator = target.aggregator === "none" ? '' : '._' + 
target.aggregator;
             var metricTransform = !target.transform || target.transform === 
"none" ? '' : '._' + target.transform;
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
-            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.sTopoMetric + metricTransform + 
'&instanceId=' + target.templatedCluster
+            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.sTopoMetric + metricTransform + 
instanceId
                 + metricAggregator + '&appId=nimbus&startTime=' + from + 
'&endTime=' + to + precision + seriesAggregator }).then(
                 allHostMetricsData(target)
             );
@@ -336,12 +344,13 @@ define([
 
           // Druid calls.
           var getDruidData = function(target) {
+            var instanceId = typeof target.templatedCluster == 'undefined'  ? 
'' : '&instanceId=' + target.templatedCluster;
             var precision = target.precision === 'default' || typeof 
target.precision == 'undefined'  ? '' : '&precision='
             + target.precision;
             var metricAggregator = target.aggregator === "none" ? '' : '._' + 
target.aggregator;
             var metricTransform = !target.transform || target.transform === 
"none" ? '' : '._' + target.transform;
             var seriesAggregator = !target.seriesAggregator || 
target.seriesAggregator === "none" ? '' : '&seriesAggregateFunction=' + 
target.seriesAggregator;
-            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.sDataSourceMetric + 
metricTransform + '&instanceId=' + target.templatedCluster
+            return self.doAmbariRequest({ url: 
'/ws/v1/timeline/metrics?metricNames=' + target.sDataSourceMetric + 
metricTransform + instanceId
                           + metricAggregator + '&appId=druid&startTime=' + 
from + '&endTime=' + to + precision + seriesAggregator }).then(
                           allHostMetricsData(target)
             );
@@ -512,7 +521,13 @@ define([
               });
             }
             // To speed up querying on templatized dashboards.
-            if (templateSrv.variables[2] && templateSrv.variables[2].name === 
"hosts") {
+              var indexOfHosts = -1;
+              for (var i = 0; i < templateSrv.variables.length; i++) {
+                  if (templateSrv.variables[i].name == 'hosts') {
+                      indexOfHosts = i;
+                  }
+              }
+              if (indexOfHosts >= 0) {
               var allHosts = templateSrv._values.hosts.lastIndexOf('}') > 0 ? 
templateSrv._values.hosts.slice(1,-1) :
               templateSrv._values.hosts;
               allHosts = templateSrv._texts.hosts === "All" ? '%' : allHosts;

http://git-wip-us.apache.org/repos/asf/ambari/blob/07d6ec30/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/files/grafana-dashboards/HDF/grafana-nifi-hosts.json
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/files/grafana-dashboards/HDF/grafana-nifi-hosts.json
 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/files/grafana-dashboards/HDF/grafana-nifi-hosts.json
index 94aa285..e491a38 100644
--- 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/files/grafana-dashboards/HDF/grafana-nifi-hosts.json
+++ 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/files/grafana-dashboards/HDF/grafana-nifi-hosts.json
@@ -965,7 +965,7 @@
         "includeAll": false,
         "multi": false,
         "multiFormat": "glob",
-        "name": "component",
+        "name": "components",
         "options": [
           {
             "selected": true,
@@ -979,6 +979,21 @@
       },
       {
         "allFormat": "glob",
+        "current": null,
+        "datasource": null,
+        "includeAll": false,
+        "label": "Cluster",
+        "multi": false,
+        "multiFormat": "glob",
+        "name": "cluster",
+        "options": [],
+        "query": "cluster",
+        "refresh": true,
+        "regex": "",
+        "type": "query"
+      },
+      {
+        "allFormat": "glob",
         "current": {
           "text": "All",
           "value": ""

Reply via email to