Merge PR #618
This commit is contained in:
@@ -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 #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 #618](https://github.com/grafana/grafana/issues/618). OpenTSDB: Series alias option to override metric name returned from opentsdb. Thanks @heldr
|
||||
|
||||
**Changes**
|
||||
- [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 @@
|
||||
<ul class="grafana-segment-list" role="menu">
|
||||
<li>
|
||||
<input type="text"
|
||||
class="input-xxlarge grafana-target-segment-input"
|
||||
class="grafana-target-segment-input"
|
||||
ng-model="target.metric"
|
||||
spellcheck='false'
|
||||
bs-typeahead="suggestMetrics"
|
||||
@@ -57,8 +57,9 @@
|
||||
<i class="icon-warning-sign"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li class="grafana-target-segment">
|
||||
<li class="grafana-target-segment">
|
||||
Aggregator
|
||||
</li>
|
||||
<li>
|
||||
<select ng-model="target.aggregator"
|
||||
class="grafana-target-segment-input input-small"
|
||||
@@ -88,6 +89,20 @@
|
||||
ng-model="target.isCounter"
|
||||
ng-change="targetBlur()">
|
||||
</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>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
||||
@@ -15,6 +15,7 @@ function (angular, _, kbn) {
|
||||
this.editorSrc = 'app/partials/opentsdb/editor.html';
|
||||
this.url = datasource.url;
|
||||
this.name = datasource.name;
|
||||
this.supportMetrics = true;
|
||||
}
|
||||
|
||||
// Called once per panel (graph)
|
||||
@@ -38,12 +39,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 +81,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 +102,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.alias) {
|
||||
return options.alias;
|
||||
}
|
||||
|
||||
return { target: target, datapoints: dps };
|
||||
if (!_.isEmpty(tagData)) {
|
||||
metric += "{" + tagData.join(", ") + "}";
|
||||
}
|
||||
|
||||
return metric;
|
||||
}
|
||||
|
||||
function convertTargetToQuery(target) {
|
||||
|
||||
Reference in New Issue
Block a user