diff --git a/api/api.go b/api/api.go index e64738bf..b9e2ef15 100644 --- a/api/api.go +++ b/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