mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
feat(prometheus): added special regex escape for prometheus, fixes #4234
This commit is contained in:
parent
e7ef79e0d3
commit
8ed8bfb8bc
@ -39,13 +39,22 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
||||
return backendSrv.datasourceRequest(options);
|
||||
};
|
||||
|
||||
function regexEscape(value) {
|
||||
return value.replace(/[\\^$*+?.()|[\]{}]/g, '\\\\$&');
|
||||
}
|
||||
|
||||
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);
|
||||
if (typeof value === 'string') {
|
||||
return regexEscape(value);
|
||||
}
|
||||
|
||||
var escapedValues = _.map(value, regexEscape);
|
||||
return escapedValues.join('|');
|
||||
};
|
||||
|
||||
// Called once per panel (graph)
|
||||
|
Loading…
Reference in New Issue
Block a user