fix(prometheus): fixed templating issue with prometheus for when using variable with non regex operator, #2918

This commit is contained in:
Torkel Ödegaard
2016-03-01 21:35:55 +01:00
parent df67d57bca
commit 0da4168836
2 changed files with 24 additions and 11 deletions

View File

@@ -39,6 +39,15 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
return backendSrv.datasourceRequest(options);
};
function interpolateQueryExpr(value, variable, defaultFormatFn) {
// if no multi or include all do not regexEscape
if (!variable.multi && !variable.includeAll) {
return value;
}
return defaultFormatFn(value, 'regex', variable);
};
// Called once per panel (graph)
this.query = function(options) {
var start = getPrometheusTime(options.range.from, false);
@@ -52,7 +61,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
}
var query: any = {};
query.expr = templateSrv.replace(target.expr, options.scopedVars, 'regex');
query.expr = templateSrv.replace(target.expr, options.scopedVars, interpolateQueryExpr);
var interval = target.interval || options.interval;
var intervalFactor = target.intervalFactor || 1;