mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-25 15:42:18 +00:00
Fix matchLabels logic
This commit is contained in:
parent
5ddf0444c4
commit
4c98f4b4a9
24
api/api.go
24
api/api.go
@ -695,16 +695,30 @@ func matchFilterLabels(matchers []*labels.Matcher, sms map[string]string) bool {
|
||||
for _, m := range matchers {
|
||||
v, prs := sms[m.Name]
|
||||
switch m.Type {
|
||||
case labels.MatchNotEqual, labels.MatchNotRegexp:
|
||||
if string(v) == "" && prs {
|
||||
return true
|
||||
case labels.MatchNotRegexp:
|
||||
if string(m.Value) == "^(?:)$" && prs {
|
||||
continue
|
||||
}
|
||||
if !m.Matches(string(v)) {
|
||||
return false
|
||||
}
|
||||
case labels.MatchRegexp:
|
||||
if string(m.Value) == "^(?:)$" && !prs {
|
||||
continue
|
||||
}
|
||||
if !m.Matches(string(v)) {
|
||||
return false
|
||||
}
|
||||
case labels.MatchNotEqual:
|
||||
if string(m.Value) == "" && prs {
|
||||
continue
|
||||
}
|
||||
if !m.Matches(string(v)) {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
if string(v) == "" && !prs {
|
||||
return true
|
||||
if string(m.Value) == "" && !prs {
|
||||
continue
|
||||
}
|
||||
if !prs || !m.Matches(string(v)) {
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user