Skip to content

Commit

Permalink
Merge pull request #144 from fluxcd/fix-exclusion-list
Browse files Browse the repository at this point in the history
Fix alerts regex filtering
  • Loading branch information
stefanprodan authored Feb 23, 2021
2 parents f8ae11c + c640ea8 commit f280418
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/server/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f280418

Please sign in to comment.