Commit f64bcf0d by Torkel Ödegaard

Merge branch 'master' of github.com:heldr/grafana into heldr-master

parents c48b6e23 1f283d93
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<ul class="grafana-segment-list" role="menu"> <ul class="grafana-segment-list" role="menu">
<li> <li>
<input type="text" <input type="text"
class="input-xxlarge grafana-target-segment-input" class="grafana-target-segment-input"
ng-model="target.metric" ng-model="target.metric"
spellcheck='false' spellcheck='false'
bs-typeahead="suggestMetrics" bs-typeahead="suggestMetrics"
...@@ -57,6 +57,16 @@ ...@@ -57,6 +57,16 @@
<i class="icon-warning-sign"></i> <i class="icon-warning-sign"></i>
</a> </a>
</li> </li>
<li>
<input type="text"
class="grafana-target-segment-input"
ng-model="target.chartLabel"
spellcheck='false'
placeholder="chart label(optional)"
data-min-length=0 data-items=100
ng-blur="targetBlur()"
/>
</li>
<li class="grafana-target-segment"> <li class="grafana-target-segment">
Aggregator Aggregator
<li> <li>
......
...@@ -38,12 +38,12 @@ function (angular, _, kbn) { ...@@ -38,12 +38,12 @@ function (angular, _, kbn) {
}); });
return this.performTimeSeriesQuery(queries, start, end) return this.performTimeSeriesQuery(queries, start, end)
.then(function(response) { .then(_.bind(function(response) {
var result = _.map(response.data, function(metricData) { var result = _.map(response.data, _.bind(function(metricData, index) {
return transformMetricData(metricData, groupByTags); return transformMetricData(metricData, groupByTags, this.targets[index]);
}); }, this));
return { data: result }; return { data: result };
}); }, options));
}; };
OpenTSDBDatasource.prototype.performTimeSeriesQuery = function(queries, start, end) { OpenTSDBDatasource.prototype.performTimeSeriesQuery = function(queries, start, end) {
...@@ -80,8 +80,20 @@ function (angular, _, kbn) { ...@@ -80,8 +80,20 @@ function (angular, _, kbn) {
}); });
}; };
function transformMetricData(md, groupByTags) { function transformMetricData(md, groupByTags, options) {
var dps = []; var dps = [],
tagData = [],
metricLabel = null;
if (!_.isEmpty(md.tags)) {
_.each(_.pairs(md.tags), function(tag) {
if (_.has(groupByTags, tag[0])) {
tagData.push(tag[0] + "=" + tag[1]);
}
});
}
metricLabel = createMetricLabel(md.metric, tagData, options);
// TSDB returns datapoints has a hash of ts => value. // TSDB returns datapoints has a hash of ts => value.
// Can't use _.pairs(invert()) because it stringifies keys/values // Can't use _.pairs(invert()) because it stringifies keys/values
...@@ -89,22 +101,19 @@ function (angular, _, kbn) { ...@@ -89,22 +101,19 @@ function (angular, _, kbn) {
dps.push([v, k]); dps.push([v, k]);
}); });
var target = md.metric; return { target: metricLabel, datapoints: dps };
if (!_.isEmpty(md.tags)) { }
var tagData = [];
_.each(_.pairs(md.tags), function(tag) { function createMetricLabel(metric, tagData, options) {
if (_.has(groupByTags, tag[0])) { if (options.chartLabel) {
tagData.push(tag[0] + "=" + tag[1]); return options.chartLabel;
} }
});
if (!_.isEmpty(tagData)) { if (!_.isEmpty(tagData)) {
target = target + "{" + tagData.join(", ") + "}"; metric += "{" + tagData.join(", ") + "}";
}
} }
return { target: target, datapoints: dps }; return metric;
} }
function convertTargetToQuery(target) { function convertTargetToQuery(target) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment