File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 9
9
LogLevel ,
10
10
} from '@grafana/data' ;
11
11
import { Observable } from 'rxjs' ;
12
- import { getBackendSrv } from '@grafana/runtime' ;
12
+ import { getBackendSrv , getTemplateSrv } from '@grafana/runtime' ;
13
13
import { queryLogsVolume } from './features/log/LogsModel' ;
14
14
15
15
import { MyQuery , MyDataSourceOptions , CachedQuery } from './types' ;
@@ -45,9 +45,19 @@ export class DataSource
45
45
this . timestampColumn = instanceSettings . jsonData . timestamp_column ;
46
46
}
47
47
48
+ applyTemplateVariables ( query : MyQuery , scopedVars : any ) : MyQuery {
49
+ return {
50
+ ...query ,
51
+ query : getTemplateSrv ( ) . replace ( query . query || '' , scopedVars ) ,
52
+ } ;
53
+ }
54
+
48
55
async query ( options : DataQueryRequest < MyQuery > ) : Promise < DataQueryResponse > {
49
56
const timestamps = getConsumableTime ( options . range ) ;
50
- const promises = options . targets . map ( ( target ) => {
57
+ const interpolatedTargets = options . targets . map ( ( target ) => {
58
+ return this . applyTemplateVariables ( target , options . scopedVars ) ;
59
+ } ) ;
60
+ const promises = interpolatedTargets . map ( ( target ) => {
51
61
if ( ! this . cachedQuery . data ) {
52
62
this . cachedQuery . data = new Promise ( ( resolve , reject ) => {
53
63
this . cachedQuery . promise = {
You can’t perform that action at this time.
0 commit comments