diff --git a/cmd/bosun/sched/silence.go b/cmd/bosun/sched/silence.go index a333270374..57d2b91371 100644 --- a/cmd/bosun/sched/silence.go +++ b/cmd/bosun/sched/silence.go @@ -39,12 +39,19 @@ func (s *Silence) MarshalJSON() ([]byte, error) { } func (s *Silence) Silenced(now time.Time, alert string, tags opentsdb.TagSet) bool { - if now.Before(s.Start) || now.After(s.End) { + if !s.ActiveAt(now) { return false } return s.Matches(alert, tags) } +func (s *Silence) ActiveAt(now time.Time) bool { + if now.Before(s.Start) || now.After(s.End) { + return false + } + return true +} + func (s *Silence) Matches(alert string, tags opentsdb.TagSet) bool { if s.Alert != "" && s.Alert != alert { return false @@ -75,6 +82,9 @@ func (s *Schedule) Silenced() map[expr.AlertKey]Silence { now := time.Now() s.Lock("Silenced") for _, si := range s.Silence { + if !si.ActiveAt(now) { + continue + } for ak := range s.status { if si.Silenced(now, ak.Name(), ak.Group()) { if aks[ak].End.Before(si.End) {