Prometheus: Replace pre-calculated $__interval values for backend interpolation (#79645)

This commit is contained in:
Dominik Prokop 2023-12-18 16:52:33 +01:00 committed by GitHub
parent 110a41b3db
commit ecb5d94b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -883,9 +883,14 @@ export class PrometheusDatasource
applyTemplateVariables(target: PromQuery, scopedVars: ScopedVars, filters?: AdHocVariableFilter[]) {
const variables = cloneDeep(scopedVars);
// We want to interpolate these variables on backend
delete variables.__interval;
delete variables.__interval_ms;
// We want to interpolate these variables on backend.
// The pre-calculated values are replaced withe the variable strings.
variables.__interval = {
value: '$__interval',
};
variables.__interval_ms = {
value: '$__interval_ms',
};
// interpolate expression
const expr = this.templateSrv.replace(target.expr, variables, this.interpolateQueryExpr);