Commit ad337344 by Ivana Huckova Committed by GitHub

Prometheus: Correctly format multi values variables in queries (#26896)

parent 0a40862a
......@@ -500,7 +500,7 @@ describe('PrometheusDatasource', () => {
});
it('should return pipe separated values if the value is an array of strings', () => {
expect(ds.interpolateQueryExpr(['a|bc', 'de|f'], customVariable)).toEqual('a\\\\|bc|de\\\\|f');
expect(ds.interpolateQueryExpr(['a|bc', 'de|f'], customVariable)).toEqual('(a\\\\|bc|de\\\\|f)');
});
});
......@@ -514,7 +514,7 @@ describe('PrometheusDatasource', () => {
});
it('should return pipe separated values if the value is an array of strings', () => {
expect(ds.interpolateQueryExpr(['a|bc', 'de|f'], customVariable)).toEqual('a\\\\|bc|de\\\\|f');
expect(ds.interpolateQueryExpr(['a|bc', 'de|f'], customVariable)).toEqual('(a\\\\|bc|de\\\\|f)');
});
});
});
......
......@@ -159,7 +159,7 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
}
const escapedValues = value.map(val => prometheusSpecialRegexEscape(val));
return escapedValues.join('|');
return '(' + escapedValues.join('|') + ')';
}
targetContainsTemplate(target: PromQuery) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment