You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
758 B

import { Matcher } from 'app/plugins/datasource/alertmanager/types';
import { Labels } from '@grafana/data';
import { parseMatcher } from './alertmanager';
// parses comma separated matchers like "foo=bar,baz=~bad*" into SilenceMatcher[]
export function parseQueryParamMatchers(paramValue: string): Matcher[] {
return paramValue
.split(',')
.filter((x) => !!x.trim())
.map((x) => parseMatcher(x.trim()));
}
export const getMatcherQueryParams = (labels: Labels) => {
return `matchers=${encodeURIComponent(
Object.entries(labels)
.filter(([labelKey]) => !(labelKey.startsWith('__') && labelKey.endsWith('__')))
.map(([labelKey, labelValue]) => {
return `${labelKey}=${labelValue}`;
})
.join(',')
)}`;
};