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 {
tsdbVersions = [
{name: '<=2.1', value: 1},
{name: '>=2.2', value: 2},
{name: '==2.2', value: 2},
{name: '==2.3', value: 3},
];
tsdbResolutions = [
......
......@@ -54,13 +54,12 @@ function (angular, _, dateMath) {
});
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) {
index = metricToTargetMapping[index];
if (index === -1) {
index = 0;
}
this._saveTagKeys(metricData);
return transformMetricData(metricData, groupByTags, options.targets[index], options, this.tsdbResolution);
......@@ -114,6 +113,9 @@ function (angular, _, dateMath) {
msResolution: msResolution,
globalAnnotations: true
};
if (this.tsdbVersion === 3) {
reqBody.showQuery = true;
}
// Relative queries (e.g. last hour) don't include an end time
if (end) {
......@@ -393,23 +395,27 @@ function (angular, _, dateMath) {
return query;
}
function mapMetricsToTargets(metrics, options) {
function mapMetricsToTargets(metrics, options, tsdbVersion) {
var interpolatedTagValue;
return _.map(metrics, function(metricData) {
return _.findIndex(options.targets, function(target) {
if (target.filters && target.filters.length > 0) {
return target.metric === metricData.metric &&
_.all(target.filters, function(filter) {
return filter.tagk === interpolatedTagValue === "*";
});
} else {
return target.metric === metricData.metric &&
_.all(target.tags, function(tagV, tagK) {
interpolatedTagValue = templateSrv.replace(tagV, options.scopedVars, 'pipe');
return metricData.tags[tagK] === interpolatedTagValue || interpolatedTagValue === "*";
});
}
});
if (tsdbVersion === 3) {
return metricData.query.index;
} else {
return _.findIndex(options.targets, function(target) {
if (target.filters && target.filters.length > 0) {
return target.metric === metricData.metric &&
_.all(target.filters, function(filter) {
return filter.tagk === interpolatedTagValue === "*";
});
} else {
return target.metric === metricData.metric &&
_.all(target.tags, function(tagV, tagK) {
interpolatedTagValue = templateSrv.replace(tagV, options.scopedVars, 'pipe');
return metricData.tags[tagK] === interpolatedTagValue || interpolatedTagValue === "*";
});
}
});
}
});
}
......
......@@ -69,7 +69,7 @@
</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>
<div class="gf-form-select-wrapper">
<select ng-model="ctrl.target.downsampleFillPolicy" class="gf-form-input"
......@@ -91,7 +91,7 @@
</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">
<label class="gf-form-label query-keyword width-8">
......@@ -170,7 +170,7 @@
<div class="gf-form">
<label class="gf-form-label query-keyword width-8">
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
</info-popover>
</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