Commit a6d25908 by Torkel Ödegaard

Merge PR #618

parents c48b6e23 923cd045
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
- [Issue #556](https://github.com/grafana/grafana/issues/556). Chart: New legend display option "Right side", will show legend to the right of the graph - [Issue #556](https://github.com/grafana/grafana/issues/556). Chart: New legend display option "Right side", will show legend to the right of the graph
- [Issue #604](https://github.com/grafana/grafana/issues/604). Chart: New axis format, 'bps' (SI unit in steps of 1000) useful for network gear metics - [Issue #604](https://github.com/grafana/grafana/issues/604). Chart: New axis format, 'bps' (SI unit in steps of 1000) useful for network gear metics
- [Issue #626](https://github.com/grafana/grafana/issues/626). Chart: Downscale y axis to more precise unit, value of 0.1 for seconds format will be formated as 100 ms. Thanks @kamaradclimber - [Issue #626](https://github.com/grafana/grafana/issues/626). Chart: Downscale y axis to more precise unit, value of 0.1 for seconds format will be formated as 100 ms. Thanks @kamaradclimber
- [Issue #618](https://github.com/grafana/grafana/issues/618). OpenTSDB: Series alias option to override metric name returned from opentsdb. Thanks @heldr
**Changes** **Changes**
- [Issue #536](https://github.com/grafana/grafana/issues/536). Graphite: Use unix epoch for Graphite from/to for absolute time ranges - [Issue #536](https://github.com/grafana/grafana/issues/536). Graphite: Use unix epoch for Graphite from/to for absolute time ranges
......
...@@ -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"
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
</li> </li>
<li class="grafana-target-segment"> <li class="grafana-target-segment">
Aggregator Aggregator
</li>
<li> <li>
<select ng-model="target.aggregator" <select ng-model="target.aggregator"
class="grafana-target-segment-input input-small" class="grafana-target-segment-input input-small"
...@@ -88,6 +89,20 @@ ...@@ -88,6 +89,20 @@
ng-model="target.isCounter" ng-model="target.isCounter"
ng-change="targetBlur()"> ng-change="targetBlur()">
</li> </li>
<li class="grafana-target-segment">
Alias:
</li>
<li>
<input type="text"
class="grafana-target-segment-input input-medium"
ng-model="target.alias"
spellcheck='false'
placeholder="series alias"
data-min-length=0 data-items=100
ng-blur="targetBlur()"
/>
</li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
......
...@@ -15,6 +15,7 @@ function (angular, _, kbn) { ...@@ -15,6 +15,7 @@ function (angular, _, kbn) {
this.editorSrc = 'app/partials/opentsdb/editor.html'; this.editorSrc = 'app/partials/opentsdb/editor.html';
this.url = datasource.url; this.url = datasource.url;
this.name = datasource.name; this.name = datasource.name;
this.supportMetrics = true;
} }
// Called once per panel (graph) // Called once per panel (graph)
...@@ -38,12 +39,12 @@ function (angular, _, kbn) { ...@@ -38,12 +39,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 +81,20 @@ function (angular, _, kbn) { ...@@ -80,8 +81,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 +102,19 @@ function (angular, _, kbn) { ...@@ -89,22 +102,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.alias) {
tagData.push(tag[0] + "=" + tag[1]); return options.alias;
} }
});
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