diff --git a/public/app/features/alerting/unified/utils/alertmanager.test.ts b/public/app/features/alerting/unified/utils/alertmanager.test.ts index 2fd657a6a1b..c830d17a1f5 100644 --- a/public/app/features/alerting/unified/utils/alertmanager.test.ts +++ b/public/app/features/alerting/unified/utils/alertmanager.test.ts @@ -90,6 +90,17 @@ describe('Alertmanager utils', () => { ]); }); + it('should parse with spaces in the value', () => { + expect(parseMatchers('foo=bar bazz')).toEqual([ + { + name: 'foo', + value: 'bar bazz', + isRegex: false, + isEqual: true, + }, + ]); + }); + it('should return nothing for invalid operator', () => { expect(parseMatchers('foo=!bar')).toEqual([]); }); diff --git a/public/app/features/alerting/unified/utils/alertmanager.ts b/public/app/features/alerting/unified/utils/alertmanager.ts index 836efd206e9..d21483d9fbe 100644 --- a/public/app/features/alerting/unified/utils/alertmanager.ts +++ b/public/app/features/alerting/unified/utils/alertmanager.ts @@ -165,7 +165,7 @@ export function matcherToObjectMatcher(matcher: Matcher): ObjectMatcher { } export function parseMatchers(matcherQueryString: string): Matcher[] { - const matcherRegExp = /\b([\w.-]+)(=~|!=|!~|=(?="?\w))"?([^"\n,} ]*)"?/g; + const matcherRegExp = /\b([\w.-]+)(=~|!=|!~|=(?="?\w))"?([^"\n,}]*)"?/g; const matchers: Matcher[] = []; matcherQueryString.replace(matcherRegExp, (_, key, operator, value) => {