Commit 7bc15ec6 by Utkarsh Bhatnagar Committed by Torkel Ödegaard

[Bug Fix] Opentsdb Alias issue (#4910)

* Fixed Opentsdb Alias issue

* Fixed Opentsdb query editor
parent e5021157
...@@ -16,7 +16,8 @@ export class OpenTsConfigCtrl { ...@@ -16,7 +16,8 @@ export class OpenTsConfigCtrl {
tsdbVersions = [ tsdbVersions = [
{name: '<=2.1', value: 1}, {name: '<=2.1', value: 1},
{name: '>=2.2', value: 2}, {name: '==2.2', value: 2},
{name: '==2.3', value: 3},
]; ];
tsdbResolutions = [ tsdbResolutions = [
......
...@@ -54,13 +54,12 @@ function (angular, _, dateMath) { ...@@ -54,13 +54,12 @@ function (angular, _, dateMath) {
}); });
return this.performTimeSeriesQuery(queries, start, end).then(function(response) { return this.performTimeSeriesQuery(queries, start, end).then(function(response) {
var metricToTargetMapping = mapMetricsToTargets(response.data, options); var metricToTargetMapping = mapMetricsToTargets(response.data, options, this.tsdbVersion);
var result = _.map(response.data, function(metricData, index) { var result = _.map(response.data, function(metricData, index) {
index = metricToTargetMapping[index]; index = metricToTargetMapping[index];
if (index === -1) { if (index === -1) {
index = 0; index = 0;
} }
this._saveTagKeys(metricData); this._saveTagKeys(metricData);
return transformMetricData(metricData, groupByTags, options.targets[index], options, this.tsdbResolution); return transformMetricData(metricData, groupByTags, options.targets[index], options, this.tsdbResolution);
...@@ -114,6 +113,9 @@ function (angular, _, dateMath) { ...@@ -114,6 +113,9 @@ function (angular, _, dateMath) {
msResolution: msResolution, msResolution: msResolution,
globalAnnotations: true globalAnnotations: true
}; };
if (this.tsdbVersion === 3) {
reqBody.showQuery = true;
}
// Relative queries (e.g. last hour) don't include an end time // Relative queries (e.g. last hour) don't include an end time
if (end) { if (end) {
...@@ -393,9 +395,12 @@ function (angular, _, dateMath) { ...@@ -393,9 +395,12 @@ function (angular, _, dateMath) {
return query; return query;
} }
function mapMetricsToTargets(metrics, options) { function mapMetricsToTargets(metrics, options, tsdbVersion) {
var interpolatedTagValue; var interpolatedTagValue;
return _.map(metrics, function(metricData) { return _.map(metrics, function(metricData) {
if (tsdbVersion === 3) {
return metricData.query.index;
} else {
return _.findIndex(options.targets, function(target) { return _.findIndex(options.targets, function(target) {
if (target.filters && target.filters.length > 0) { if (target.filters && target.filters.length > 0) {
return target.metric === metricData.metric && return target.metric === metricData.metric &&
...@@ -410,6 +415,7 @@ function (angular, _, dateMath) { ...@@ -410,6 +415,7 @@ function (angular, _, dateMath) {
}); });
} }
}); });
}
}); });
} }
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
</div> </div>
</div> </div>
<div class="gf-form" ng-if="ctrl.tsdbVersion == 2"> <div class="gf-form" ng-if="ctrl.tsdbVersion >= 2">
<label class="gf-form-label query-keyword width-6">Fill</label> <label class="gf-form-label query-keyword width-6">Fill</label>
<div class="gf-form-select-wrapper"> <div class="gf-form-select-wrapper">
<select ng-model="ctrl.target.downsampleFillPolicy" class="gf-form-input" <select ng-model="ctrl.target.downsampleFillPolicy" class="gf-form-input"
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
</div> </div>
</div> </div>
<div class="gf-form-inline" ng-if="ctrl.tsdbVersion == 2"> <div class="gf-form-inline" ng-if="ctrl.tsdbVersion >= 2">
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-8"> <label class="gf-form-label query-keyword width-8">
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label query-keyword width-8"> <label class="gf-form-label query-keyword width-8">
Tags Tags
<info-popover mode="right-normal" ng-if="ctrl.tsdbVersion == 2"> <info-popover mode="right-normal" ng-if="ctrl.tsdbVersion >= 2">
Please use filters, tags are deprecated in opentsdb 2.2 Please use filters, tags are deprecated in opentsdb 2.2
</info-popover> </info-popover>
</label> </label>
......
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