Skip to content

Commit ae95470

Browse files
authored
feat: make variables used in queries work (#28)
1 parent 74b7240 commit ae95470

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/datasource.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getBackendSrv, BackendSrvRequest, FetchResponse } from "@grafana/runtime";
1+
import { getBackendSrv, getTemplateSrv, BackendSrvRequest, FetchResponse } from "@grafana/runtime";
22
import {
33
DataQueryRequest,
44
DataQueryResponse,
@@ -58,12 +58,15 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
5858
const end = range!.to;
5959

6060
const calls = options.targets.map(target => {
61+
const query = getTemplateSrv().replace(target.queryText, options.scopedVars);
62+
6163
const request = {
62-
"query": target.queryText,
64+
"query": query,
6365
"startTime": start.toISOString(),
6466
"endTime": end.toISOString(),
6567
"send_null": true
6668
};
69+
6770
return lastValueFrom(
6871
this.doFetch<any[]>({
6972
url: this.url + '/api/v1/query',

0 commit comments

Comments
 (0)