AMBARI-15343. Alias for metrics in ambari-metrics-grafana. (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/5e69da9d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5e69da9d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5e69da9d Branch: refs/heads/AMBARI-13364 Commit: 5e69da9d0c5ca21d6e046cf7c7ab5b9c21063fba Parents: ec4b1d1 Author: Yusaku Sako <yus...@hortonworks.com> Authored: Tue Mar 8 21:23:04 2016 -0800 Committer: Yusaku Sako <yus...@hortonworks.com> Committed: Tue Mar 8 21:23:04 2016 -0800 ---------------------------------------------------------------------- .../ambari-metrics/datasource.js | 7 +++++-- .../ambari-metrics/partials/query.editor.html | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/5e69da9d/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 3e665e0..fa83b47 100644 --- a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js +++ b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/datasource.js @@ -94,6 +94,9 @@ define([ }; var self = this; var getMetricsData = function (target) { + var alias = target.alias ? target.alias : target.metric; + if(!_.isEmpty(templateSrv.variables) && templateSrv.variables[0].query === "yarnqueues") { + alias = alias + ' on ' + target.qmetric; } return function (res) { console.log('processing metric ' + target.metric); if (!res.metrics[0] || target.hide) { @@ -106,12 +109,12 @@ define([ var timeSeries = {}; if (target.hosts === undefined || target.hosts.trim() === "") { timeSeries = { - target: res.metrics[0].metricname + hostLegend, + target: alias + hostLegend, datapoints: [] }; } else { timeSeries = { - target: target.metric + ' on ' + target.hosts, + target: alias + ' on ' + target.hosts, datapoints: [] }; } http://git-wip-us.apache.org/repos/asf/ambari/blob/5e69da9d/ambari-metrics/ambari-metrics-grafana/ambari-metrics/partials/query.editor.html ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/partials/query.editor.html b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/partials/query.editor.html index f51866e..fed38ac 100644 --- a/ambari-metrics/ambari-metrics-grafana/ambari-metrics/partials/query.editor.html +++ b/ambari-metrics/ambari-metrics-grafana/ambari-metrics/partials/query.editor.html @@ -117,6 +117,20 @@ <div class="tight-form"> <ul class="tight-form-list" role="menu"> <li class="tight-form-item tight-form-align" style="width: 86px"> + Alias + </li> + <li> + <input type="text" class="tight-form-input input-large" + ng-model="target.alias" + spellcheck='false' + placeholder="series alias" + data-min-length=0 data-items=100 + ng-blur="targetBlur()"></input> + <a bs-tooltip="target.errors.metric" style="color: rgb(229, 189, 28)" ng-show="target.errors.metric"> + <i class="fa fa-warning"></i> + </a> + </li> + <li class="tight-form-item tight-form-align" style="width: 86px"> <editor-checkbox text="Rate" model="target.shouldComputeRate" change="targetBlur()"></editor-checkbox> </li>