Skip to content

Commit

Permalink
send notification only change of status #538
Browse files Browse the repository at this point in the history
Add 'send-once' option to notifier so the alert will only be sent once.
example config:
[notifier.tellmeonce]
class-name="email"
interval=60
threshold=2
send-close=true
send-once=true
from=
to=
...
  • Loading branch information
meimeil committed Oct 23, 2019
1 parent 46e352a commit 704df4b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/internal/notifier/coordinator.go
Expand Up @@ -553,6 +553,11 @@ func (nc *Coordinator) notifyModule(module Module, status *protocol.ConsumerGrou
return
}

// Only send the open notification once if send-once is configured
if (!cgroup.LastNotify[module.GetName()].IsZero()) && viper.GetBool("notifier."+moduleName+".send-once") {
return
}

// Only send the notification if it's been at least our Interval since the last one for this group
currentTime := time.Now()
if currentTime.Sub(cgroup.LastNotify[module.GetName()]) > (time.Duration(viper.GetInt("notifier."+moduleName+".send-interval")) * time.Second) {
Expand Down

0 comments on commit 704df4b

Please sign in to comment.