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 99 LogLevel ,
1010} from '@grafana/data' ;
1111import { Observable } from 'rxjs' ;
12- import { getBackendSrv } from '@grafana/runtime' ;
12+ import { getBackendSrv , getTemplateSrv } from '@grafana/runtime' ;
1313import { queryLogsVolume } from './features/log/LogsModel' ;
1414
1515import { MyQuery , MyDataSourceOptions , CachedQuery } from './types' ;
@@ -45,9 +45,19 @@ export class DataSource
4545 this . timestampColumn = instanceSettings . jsonData . timestamp_column ;
4646 }
4747
48+ applyTemplateVariables ( query : MyQuery , scopedVars : any ) : MyQuery {
49+ return {
50+ ...query ,
51+ query : getTemplateSrv ( ) . replace ( query . query || '' , scopedVars ) ,
52+ } ;
53+ }
54+
4855 async query ( options : DataQueryRequest < MyQuery > ) : Promise < DataQueryResponse > {
4956 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 ) => {
5161 if ( ! this . cachedQuery . data ) {
5262 this . cachedQuery . data = new Promise ( ( resolve , reject ) => {
5363 this . cachedQuery . promise = {
You can’t perform that action at this time.
0 commit comments