mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Prometheus: interpolate variable for step field (#36437)
* Prometheus: interpolate variable for step * Add test for variable interpolation
This commit is contained in:
parent
1655ff1e49
commit
55e763b4cd
@ -553,6 +553,23 @@ describe('PrometheusDatasource', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('interpolateVariablesInQueries', () => {
|
||||
it('should call replace function 2 times', () => {
|
||||
const query = {
|
||||
expr: 'test{job="testjob"}',
|
||||
format: 'time_series',
|
||||
interval: '$Interval',
|
||||
refId: 'A',
|
||||
};
|
||||
const interval = '10m';
|
||||
templateSrvStub.replace.mockReturnValue(interval);
|
||||
|
||||
const queries = ds.interpolateVariablesInQueries([query], { Interval: { text: interval, value: interval } });
|
||||
expect(templateSrvStub.replace).toBeCalledTimes(2);
|
||||
expect(queries[0].interval).toBe(interval);
|
||||
});
|
||||
});
|
||||
|
||||
describe('metricFindQuery', () => {
|
||||
beforeEach(() => {
|
||||
const query = 'query_result(topk(5,rate(http_request_duration_microseconds_count[$__interval])))';
|
||||
|
@ -735,6 +735,7 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
|
||||
...query,
|
||||
datasource: this.name,
|
||||
expr: this.templateSrv.replace(query.expr, scopedVars, this.interpolateQueryExpr),
|
||||
interval: this.templateSrv.replace(query.interval, scopedVars),
|
||||
};
|
||||
return expandedQuery;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user