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

This commit is contained in:
Ivana Huckova 2020-08-10 15:36:15 +02:00 committed by GitHub
parent 0a40862af5
commit ad33734424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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)');
});
});
});

View File

@ -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) {