diff --git a/src/app/partials/opentsdb/editor.html b/src/app/partials/opentsdb/editor.html
index 673c5a68cc4..c71fd0805c7 100644
--- a/src/app/partials/opentsdb/editor.html
+++ b/src/app/partials/opentsdb/editor.html
@@ -43,7 +43,7 @@
-
+ -
+
+
-
Aggregator
-
diff --git a/src/app/services/opentsdb/opentsdbDatasource.js b/src/app/services/opentsdb/opentsdbDatasource.js
index fddcec04d05..c34d69a4eb5 100644
--- a/src/app/services/opentsdb/opentsdbDatasource.js
+++ b/src/app/services/opentsdb/opentsdbDatasource.js
@@ -38,12 +38,12 @@ function (angular, _, kbn) {
});
return this.performTimeSeriesQuery(queries, start, end)
- .then(function(response) {
- var result = _.map(response.data, function(metricData) {
- return transformMetricData(metricData, groupByTags);
- });
+ .then(_.bind(function(response) {
+ var result = _.map(response.data, _.bind(function(metricData, index) {
+ return transformMetricData(metricData, groupByTags, this.targets[index]);
+ }, this));
return { data: result };
- });
+ }, options));
};
OpenTSDBDatasource.prototype.performTimeSeriesQuery = function(queries, start, end) {
@@ -80,8 +80,20 @@ function (angular, _, kbn) {
});
};
- function transformMetricData(md, groupByTags) {
- var dps = [];
+ function transformMetricData(md, groupByTags, options) {
+ 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.
// Can't use _.pairs(invert()) because it stringifies keys/values
@@ -89,22 +101,19 @@ function (angular, _, kbn) {
dps.push([v, k]);
});
- var target = md.metric;
- if (!_.isEmpty(md.tags)) {
- var tagData = [];
+ return { target: metricLabel, datapoints: dps };
+ }
- _.each(_.pairs(md.tags), function(tag) {
- if (_.has(groupByTags, tag[0])) {
- tagData.push(tag[0] + "=" + tag[1]);
- }
- });
-
- if (!_.isEmpty(tagData)) {
- target = target + "{" + tagData.join(", ") + "}";
- }
+ function createMetricLabel(metric, tagData, options) {
+ if (options.chartLabel) {
+ return options.chartLabel;
}
- return { target: target, datapoints: dps };
+ if (!_.isEmpty(tagData)) {
+ metric += "{" + tagData.join(", ") + "}";
+ }
+
+ return metric;
}
function convertTargetToQuery(target) {