From c640ea8e365709d42eb07ff529582ca332ab63ac Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 23 Feb 2021 12:55:57 +0200 Subject: [PATCH] Fix alerts regex filtering Signed-off-by: Stefan Prodan --- internal/server/event_handlers.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/server/event_handlers.go b/internal/server/event_handlers.go index 00402e3d7..0e6ca80dc 100644 --- a/internal/server/event_handlers.go +++ b/internal/server/event_handlers.go @@ -75,17 +75,22 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request) } // skip alert if the message matches a regex from the exclusion list + var skip bool if len(alert.Spec.ExclusionList) > 0 { for _, exp := range alert.Spec.ExclusionList { if r, err := regexp.Compile(exp); err == nil { if r.Match([]byte(event.Message)) { - continue + skip = true + break } } else { s.logger.Error(err, fmt.Sprintf("failed to compile regex: %s", exp)) } } } + if skip { + continue + } // filter alerts by object and severity for _, source := range alert.Spec.EventSources {