mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
Prometheus: Fix term completion that contain keywords (#21295)
- `unless`, `or` and `and` are binary operators - if they appear in a query the query was broken up so the suggestor only works on the current term - this change fixes the splitter logic to make sure those keywords are not inside a word
This commit is contained in:
parent
355b906493
commit
649fa6789e
@ -49,6 +49,7 @@ describe('Language completion provider', () => {
|
||||
expect(cleanText('foo < bar')).toBe('bar');
|
||||
expect(cleanText('foo >= bar')).toBe('bar');
|
||||
expect(cleanText('foo <= bar')).toBe('bar');
|
||||
expect(cleanText('memory')).toBe('memory');
|
||||
});
|
||||
|
||||
it('removes aggregation syntax', () => {
|
||||
|
@ -51,7 +51,7 @@ function addMetricsMetadata(metric: string, metadata?: PromMetricsMetadata): Com
|
||||
return item;
|
||||
}
|
||||
|
||||
const PREFIX_DELIMITER_REGEX = /(="|!="|=~"|!~"|\{|\[|\(|\+|-|\/|\*|%|\^|and|or|unless|==|>=|!=|<=|>|<|=|~|,)/;
|
||||
const PREFIX_DELIMITER_REGEX = /(="|!="|=~"|!~"|\{|\[|\(|\+|-|\/|\*|%|\^|\band\b|\bor\b|\bunless\b|==|>=|!=|<=|>|<|=|~|,)/;
|
||||
|
||||
export default class PromQlLanguageProvider extends LanguageProvider {
|
||||
histogramMetrics?: string[];
|
||||
|
Loading…
Reference in New Issue
Block a user