Files
karma/ui/src/Components/SilenceModal/Matchers.js
Łukasz Mierzwa 7d52626489 fix(ui): send silences only to a single cluster node
Silences are shared by HA cluster members, when submitting a silence to a cluster try each each member but stop after first successful fetch
2018-12-01 17:58:40 +00:00

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 };