mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Correctly format multi values variables in queries (#26896)
This commit is contained in:
@@ -500,7 +500,7 @@ describe('PrometheusDatasource', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return pipe separated values if the value is an array of strings', () => {
|
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', () => {
|
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));
|
const escapedValues = value.map(val => prometheusSpecialRegexEscape(val));
|
||||||
return escapedValues.join('|');
|
return '(' + escapedValues.join('|') + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
targetContainsTemplate(target: PromQuery) {
|
targetContainsTemplate(target: PromQuery) {
|
||||||
|
|||||||
Reference in New Issue
Block a user