This is an automated email from the ASF dual-hosted git repository. hapylestat pushed a commit to branch branch-2.7 in repository https://gitbox.apache.org/repos/asf/ambari.git
View the commit online: https://github.com/apache/ambari/commit/ff21bd18c447eb64bc76b0b53dcf3ac85a13c527 The following commit(s) were added to refs/heads/branch-2.7 by this push: new ff21bd1 AMBARI-25379 Upgrade AMS Grafana version to 6.4.2 ff21bd1 is described below commit ff21bd18c447eb64bc76b0b53dcf3ac85a13c527 Author: Tamas Payer <[email protected]> AuthorDate: Wed Nov 20 10:10:40 2019 +0100 AMBARI-25379 Upgrade AMS Grafana version to 6.4.2 Fix minor datasource related issues. Change-Id: I26a81da667cb264814828373c087bb5ad39ad945 --- .../ambari-metrics/datasource.js | 197 ++++++++++++--------- 1 file changed, 110 insertions(+), 87 deletions(-) diff --git a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js index e6be3fc..4a97f3b 100644 --- a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js +++ b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js @@ -394,31 +394,24 @@ define([ if (!_.isEmpty(templateSrv.variables)) { // YARN Queues Dashboard if (templateSrv.variables[0].query === "yarnqueues") { - var allQueues = templateSrv.variables.filter(function(variable) { return variable.query === "yarnqueues";}); - var selectedQs = (_.isEmpty(allQueues)) ? "" : allQueues[0].options.filter(function(q) - { return q.selected; }).map(function(qName) { return qName.value; }); - // All Queues - if (!_.isEmpty(_.find(selectedQs, function (wildcard) { return wildcard === "*"; }))) { - var allQueue = allQueues[0].options.filter(function(q) { - return q.text !== "All"; }).map(function(queue) { return queue.value; }); - _.forEach(allQueue, function(processQueue) { - metricsPromises.push(_.map(options.targets, function(target) { - target.qmetric = processQueue; - target.queue = target.metric.replace('root', target.qmetric); - return getYarnAppIdData(target); - })); - }); - } else { - // All selected queues. - _.forEach(selectedQs, function(processQueue) { - metricsPromises.push(_.map(options.targets, function(target) { - target.qmetric = processQueue; - target.queue = target.metric.replace('root', target.qmetric); - return getYarnAppIdData(target); - })); + var allQueues = templateSrv.variables.filter(function(variable) { + return variable.query === "yarnqueues"; + }); + var selectedQs = (_.isEmpty(allQueues)) ? "" : allQueues[0].options + .filter(getSelectedItems) + .map(function(qName) { + return qName.value; }); - } + + _.forEach(selectedQs, function(processQueue) { + metricsPromises.push(_.map(options.targets, function(target) { + target.qmetric = processQueue; + target.queue = target.metric.replace('root', target.qmetric); + return getYarnAppIdData(target); + })); + }); } + // Templatized Dashboard for per-user metrics in HBase. if (templateSrv.variables[0].query === "hbase-users") { var allUsers = templateSrv.variables.filter(function(variable) { @@ -453,8 +446,8 @@ define([ } } - while (allTable.length > 0) { - splitTables.push(allTable.splice(0, 20)); + while (allTables.length > 0) { + splitTables.push(allTables.splice(0, 20)); } _.forEach(splitTables, function(table) { metricsPromises.push(_.map(options.targets, function(target) { @@ -499,7 +492,7 @@ define([ selectedCallers.push(caller.text); } } - _.forEach(selectedCaller, function(processCaller) { + _.forEach(selectedCallers, function(processCaller) { metricsPromises.push(_.map(options.targets, function(target) { target.nnCaller = processCaller; target.nnMetric = target.metric.replace('*', target.nnCaller); @@ -571,29 +564,35 @@ define([ //Templatized Dashboards for Storm Components if (templateSrv.variables[0].query === "topologies" && templateSrv.variables[1] && templateSrv.variables[1].name === "component") { - var selectedTopology = templateSrv._values.topologies; - var selectedComponent = templateSrv._values.component; - metricsPromises.push(_.map(options.targets, function(target) { - target.sTopology = selectedTopology; - target.sComponent = selectedComponent; - target.sTopoMetric = target.metric.replace('*', target.sTopology).replace('*', target.sComponent); - return getStormData(target); - })); + if (templateSrv._values) { + var selectedTopology = templateSrv._values.topologies; + var selectedComponent = templateSrv._values.component; + + metricsPromises.push(_.map(options.targets, function(target) { + target.sTopology = selectedTopology; + target.sComponent = selectedComponent; + target.sTopoMetric = target.metric.replace('*', target.sTopology).replace('*', target.sComponent); + return getStormData(target); + })); + } } //Templatized Dashboard for Storm Kafka Offset if (templateSrv.variables[0].query === "topologies" && templateSrv.variables[1] && templateSrv.variables[1].name === "topic") { - var selectedTopology = templateSrv._values.topologies; - var selectedTopic = templateSrv._values.topic; - metricsPromises.push(_.map(options.targets, function(target) { - target.sTopology = selectedTopology; - target.sTopic = selectedTopic; - target.sPartition = options.scopedVars.partition.value; - target.sTopoMetric = target.metric.replace('*', target.sTopology).replace('*', target.sTopic) - .replace('*', target.sPartition); - return getStormData(target); - })); + if (templateSrv._values) { + var selectedTopology = templateSrv._values.topologies; + var selectedTopic = templateSrv._values.topic; + + metricsPromises.push(_.map(options.targets, function(target) { + target.sTopology = selectedTopology; + target.sTopic = selectedTopic; + target.sPartition = options.scopedVars.partition.value; + target.sTopoMetric = target.metric.replace('*', target.sTopology).replace('*', target.sTopic) + .replace('*', target.sPartition); + return getStormData(target); + })); + } } //Templatized Dashboards for Druid @@ -800,50 +799,56 @@ define([ var cores = []; //Templated Variables for Infra Solr Cores if (interpolated === "infra_solr_core") { - return this.initMetricAppidMapping() - .then(function () { - var solrMetrics = allMetrics["ambari-infra-solr"]; - var extractCores = solrMetrics.filter(/./.test.bind(new - RegExp("^infra.solr.core.", 'g'))); - _.map(extractCores, function (core) { - // Core naming convention is infra.solr.core.<collection_name>.<shard>.<replica>.<metric_name> - // coreName should be <collection_name>.<shard>.<replica> - core = core.split('.'); - var coreName = core.slice(3,6).join("."); - if (cores.indexOf(coreName) < 0) { - cores.push(coreName); - } - }); - return _.map(cores, function (cores) { - return { - text: cores - }; - }); + return this.initMetricAppidMapping() + .then(function () { + var solrMetrics = []; + if (allMetrics["ambari-infra-solr"]) { + var solrMetrics = allMetrics["ambari-infra-solr"]; + } + var extractCores = solrMetrics.filter(/./.test.bind(new + RegExp("^infra.solr.core.", 'g'))); + _.map(extractCores, function (core) { + // Core naming convention is infra.solr.core.<collection_name>.<shard>.<replica>.<metric_name> + // coreName should be <collection_name>.<shard>.<replica> + core = core.split('.'); + var coreName = core.slice(3,6).join("."); + if (cores.indexOf(coreName) < 0) { + cores.push(coreName); + } + }); + return _.map(cores, function (cores) { + return { + text: cores + }; }); + }); } var collections = []; //Templated Variables for Infra Solr Collections if (interpolated === "infra_solr_collection") { - return this.initMetricAppidMapping() - .then(function () { - var solrMetrics = allMetrics["ambari-infra-solr"]; - var extractCollections = solrMetrics.filter(/./.test.bind(new - RegExp("^infra.solr.core.", 'g'))); - _.map(extractCollections, function (core) { - // Core naming convention is infra.solr.core.<collection_name>.<shard>.<replica>.<metric_name> - core = core.split('.'); - var collection = core[3]; - if (collections.indexOf(collection) < 0) { - collections.push(collection); - } - }); - return _.map(collections, function (collections) { - return { - text: collections - }; - }); + return this.initMetricAppidMapping() + .then(function () { + var solrMetrics = []; + if (allMetrics["ambari-infra-solr"]) { + var solrMetrics = allMetrics["ambari-infra-solr"]; + } + var extractCollections = solrMetrics.filter(/./.test.bind(new + RegExp("^infra.solr.core.", 'g'))); + _.map(extractCollections, function (core) { + // Core naming convention is infra.solr.core.<collection_name>.<shard>.<replica>.<metric_name> + core = core.split('.'); + var collection = core[3]; + if (collections.indexOf(collection) < 0) { + collections.push(collection); + } + }); + return _.map(collections, function (collections) { + return { + text: collections + }; }); + }); } var topologies = {}; @@ -851,7 +856,10 @@ define([ if(interpolated === "topologies") { return this.initMetricAppidMapping() .then(function () { - var storm = allMetrics["nimbus"]; + var storm = []; + if(allMetrics["nimbus"]) { + storm = allMetrics["nimbus"]; + } var extractTopologies = storm.filter(/./.test.bind(new RegExp("^topology.", 'g'))); _.map(extractTopologies, function(topology){ @@ -875,7 +883,10 @@ define([ var componentName = interpolated.substring(0,interpolated.indexOf('.')); return this.initMetricAppidMapping() .then(function () { - var storm = allMetrics["nimbus"]; + var storm = []; + if(allMetrics["nimbus"]) { + storm = allMetrics["nimbus"]; + } var extractTopologies = storm.filter(/./.test.bind(new RegExp("^topology.", 'g'))); _.map(extractTopologies, function(topology){ @@ -902,7 +913,10 @@ define([ this.getStormEntities = function () { return this.initMetricAppidMapping() .then(function () { - var storm = allMetrics["nimbus"]; + var storm = []; + if(allMetrics["nimbus"]) { + storm = allMetrics["nimbus"]; + } var extractTopologies = storm.filter(/./.test.bind(new RegExp("partition", 'g'))); _.map(extractTopologies, function(topology){ @@ -974,7 +988,10 @@ define([ if(interpolated === "druidServices") { return this.initMetricAppidMapping() .then(function () { - var druidMetrics = allMetrics["druid"]; + var druidMetrics = []; + if(allMetrics["druid"]) { + druidMetrics = allMetrics["druid"]; + } // Assumption: each node always emits jvm metrics var extractNodeTypes = druidMetrics.filter(/./.test.bind(new RegExp("jvm/gc/time", 'g'))); var nodeTypes = _.map(extractNodeTypes, function(metricName) { @@ -994,7 +1011,10 @@ define([ if(interpolated === "druidDataSources") { return this.initMetricAppidMapping() .then(function () { - var druidMetrics = allMetrics["druid"]; + var druidMetrics = []; + if(allMetrics["druid"]) { + druidMetrics = allMetrics["druid"]; + } // Assumption: query/time is emitted for each datasource var extractDataSources = druidMetrics.filter(/./.test.bind(new RegExp("query/time", 'g'))); var dataSources = _.map(extractDataSources, function(metricName) { @@ -1014,7 +1034,10 @@ define([ if(interpolated === "druidQueryTypes") { return this.initMetricAppidMapping() .then(function () { - var druidMetrics = allMetrics["druid"]; + var druidMetrics = []; + if(allMetrics["druid"]) { + druidMetrics = allMetrics["druid"]; + } // Assumption: query/time is emitted for each query type. var extractQueryTypes = druidMetrics.filter(/./.test.bind(new RegExp("query/time", 'g'))); var queryTypes = _.map(extractQueryTypes, function(metricName) {
