mirror of
https://github.com/prymitive/karma
synced 2026-05-17 04:16:42 +00:00
Silences are shared by HA cluster members, when submitting a silence to a cluster try each each member but stop after first successful fetch
28 lines
729 B
JavaScript
28 lines
729 B
JavaScript
import { FormatQuery, QueryOperators, StaticLabels } from "Common/Query";
|
|
|
|
const MatcherToFilter = matcher => {
|
|
const operator = matcher.isRegex
|
|
? QueryOperators.Regex
|
|
: QueryOperators.Equal;
|
|
const value =
|
|
matcher.values.length > 1
|
|
? `(${matcher.values.map(v => v.value).join("|")})`
|
|
: matcher.values[0].value;
|
|
return FormatQuery(
|
|
matcher.name,
|
|
operator,
|
|
matcher.isRegex ? `^${value}$` : value
|
|
);
|
|
};
|
|
|
|
const AlertManagersToFilter = alertmanagers => {
|
|
let amNames = [].concat(...alertmanagers.map(am => am.value));
|
|
return FormatQuery(
|
|
StaticLabels.AlertManager,
|
|
QueryOperators.Regex,
|
|
`^(${amNames.join("|")})$`
|
|
);
|
|
};
|
|
|
|
export { MatcherToFilter, AlertManagersToFilter };
|