ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject ambari git commit: AMBARI-17281. [Grafana] topN implementation for templatized dashboards. (Prajwal Rao via yusaku)
Date Thu, 16 Jun 2016 19:59:02 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 9ddb9b778 -> 56f2b49bc


AMBARI-17281. [Grafana] topN implementation for templatized dashboards. (Prajwal Rao via yusaku)


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

Branch: refs/heads/branch-2.4
Commit: 56f2b49bcfbfe7251192962597117e1550c22791
Parents: 9ddb9b7
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Thu Jun 16 12:56:15 2016 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Thu Jun 16 12:58:41 2016 -0700

----------------------------------------------------------------------
 .../ambari-metrics/datasource.js                | 29 ++++++++++----------
 1 file changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/56f2b49b/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 7390aa8..b825774 100644
--- a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js
+++ b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js
@@ -194,14 +194,22 @@ define([
           };
           // To speed up querying on templatized dashboards.
           var getAllHostData = function(target) {
-            var precision = target.precision === 'default' || typeof target.precision ==
'undefined'  ? '' : '&precision=' 
+            var precision = target.precision === 'default' || typeof target.precision ==
'undefined'  ? '' : '&precision='
             + target.precision;
             var metricAggregator = target.aggregator === "none" ? '' : '._' + target.aggregator;
+            var topN = ""; var isBottomN = "";
+            if (!_.isEmpty(templateSrv.variables.filter(function(o) { return o.name === "instances";})))
{
+              var metricTopN = _.filter(templateSrv.variables, function (o) { return o.name
=== "instances"; });
+              var metricTopAgg = _.filter(templateSrv.variables, function (o) { return o.name
=== "topagg"; });
+              isBottomN = templateSrv.variables.filter(function(o) { return o.name === "orientation";})[0].current.value
+              === "bottom" ? true : false;
+              topN = '&topN=' + metricTopN[0].current.value  +'&topNFunction=' +
metricTopAgg[0].current.value  + '&isBottomN='+ isBottomN;
+            }
             var metricTransform = !target.transform || target.transform === "none" ? '' :
'._' + target.transform;
             var templatedComponent = (_.isEmpty(tComponent)) ? target.app : tComponent;
             return backendSrv.get(self.url + '/ws/v1/timeline/metrics?metricNames=' + target.metric
+ metricTransform
               + metricAggregator + '&hostname=' + target.templatedHost + '&appId='
+ templatedComponent + '&startTime=' + from +
-              '&endTime=' + to + precision).then(
+              '&endTime=' + to + precision + topN).then(
               allHostMetricsData(target)
             );
           };
@@ -352,20 +360,13 @@ define([
 
             // To speed up querying on templatized dashboards.
             if (templateSrv.variables[1] && templateSrv.variables[1].name === "hosts")
{
-              var splitHosts = [];
-              // Remove curly braces that Grafana adds. {host1,host2}
               var allHosts = templateSrv._values.hosts.lastIndexOf('}') > 0 ? templateSrv._values.hosts.slice(1,-1)
:
-                templateSrv._values.hosts;
-              var allHost = allHosts.split(',');
-              while (allHost.length > 0) {
-                splitHosts.push(allHost.splice(0,50));
-              }
-              _.forEach(splitHosts, function(splitHost) {
-                metricsPromises.push(_.map(options.targets, function(target) {
-                  target.templatedHost = _.flatten(splitHost).join(',');
+              templateSrv._values.hosts;
+              allHosts = templateSrv._texts.hosts === "All" ? '%' : allHosts;
+              metricsPromises.push(_.map(options.targets, function(target) {
+                  target.templatedHost = allHosts;
                   return getAllHostData(target);
-                }));
-              });
+              }));
             }
             metricsPromises = _.flatten(metricsPromises);
           } else {


Mime
View raw message