@@ -54,13 +54,12 @@ function (angular, _, dateMath) {
54
54
} ) ;
55
55
56
56
return this . performTimeSeriesQuery ( queries , start , end ) . then ( function ( response ) {
57
- var metricToTargetMapping = mapMetricsToTargets ( response . data , options ) ;
57
+ var metricToTargetMapping = mapMetricsToTargets ( response . data , options , this . tsdbVersion ) ;
58
58
var result = _ . map ( response . data , function ( metricData , index ) {
59
59
index = metricToTargetMapping [ index ] ;
60
60
if ( index === - 1 ) {
61
61
index = 0 ;
62
62
}
63
-
64
63
this . _saveTagKeys ( metricData ) ;
65
64
66
65
return transformMetricData ( metricData , groupByTags , options . targets [ index ] , options , this . tsdbResolution ) ;
@@ -114,6 +113,9 @@ function (angular, _, dateMath) {
114
113
msResolution : msResolution ,
115
114
globalAnnotations : true
116
115
} ;
116
+ if ( this . tsdbVersion === 3 ) {
117
+ reqBody . showQuery = true ;
118
+ }
117
119
118
120
// Relative queries (e.g. last hour) don't include an end time
119
121
if ( end ) {
@@ -393,23 +395,27 @@ function (angular, _, dateMath) {
393
395
return query ;
394
396
}
395
397
396
- function mapMetricsToTargets ( metrics , options ) {
398
+ function mapMetricsToTargets ( metrics , options , tsdbVersion ) {
397
399
var interpolatedTagValue ;
398
400
return _ . map ( metrics , function ( metricData ) {
399
- return _ . findIndex ( options . targets , function ( target ) {
400
- if ( target . filters && target . filters . length > 0 ) {
401
- return target . metric === metricData . metric &&
402
- _ . all ( target . filters , function ( filter ) {
403
- return filter . tagk === interpolatedTagValue === "*" ;
404
- } ) ;
405
- } else {
406
- return target . metric === metricData . metric &&
407
- _ . all ( target . tags , function ( tagV , tagK ) {
408
- interpolatedTagValue = templateSrv . replace ( tagV , options . scopedVars , 'pipe' ) ;
409
- return metricData . tags [ tagK ] === interpolatedTagValue || interpolatedTagValue === "*" ;
410
- } ) ;
411
- }
412
- } ) ;
401
+ if ( tsdbVersion === 3 ) {
402
+ return metricData . query . index ;
403
+ } else {
404
+ return _ . findIndex ( options . targets , function ( target ) {
405
+ if ( target . filters && target . filters . length > 0 ) {
406
+ return target . metric === metricData . metric &&
407
+ _ . all ( target . filters , function ( filter ) {
408
+ return filter . tagk === interpolatedTagValue === "*" ;
409
+ } ) ;
410
+ } else {
411
+ return target . metric === metricData . metric &&
412
+ _ . all ( target . tags , function ( tagV , tagK ) {
413
+ interpolatedTagValue = templateSrv . replace ( tagV , options . scopedVars , 'pipe' ) ;
414
+ return metricData . tags [ tagK ] === interpolatedTagValue || interpolatedTagValue === "*" ;
415
+ } ) ;
416
+ }
417
+ } ) ;
418
+ }
413
419
} ) ;
414
420
}
415
421
0 commit comments