diff --git a/public/app/plugins/datasource/opentsdb/config_ctrl.ts b/public/app/plugins/datasource/opentsdb/config_ctrl.ts index c7c90e9c17f..a9259337926 100644 --- a/public/app/plugins/datasource/opentsdb/config_ctrl.ts +++ b/public/app/plugins/datasource/opentsdb/config_ctrl.ts @@ -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 = [ diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 16f96ae060e..b683aa02068 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -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 === "*"; + }); + } + }); + } }); } diff --git a/public/app/plugins/datasource/opentsdb/partials/query.editor.html b/public/app/plugins/datasource/opentsdb/partials/query.editor.html index e4e8fc8e09f..255e23c5701 100644 --- a/public/app/plugins/datasource/opentsdb/partials/query.editor.html +++ b/public/app/plugins/datasource/opentsdb/partials/query.editor.html @@ -69,7 +69,7 @@ -
+