Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bosun: Ability to throttle log notifications #1032

Merged
merged 4 commits into from Jun 5, 2015
Merged

bosun: Ability to throttle log notifications #1032

merged 4 commits into from Jun 5, 2015

Conversation

captncraig
Copy link
Contributor

Adds maxLogFrequency key to alerts that can control how often notification gets run. Only valid on log alerts.

Fixes #975

@@ -174,6 +174,13 @@ func (s *Schedule) RunHistory(r *RunHistory) {
// If the old alert was not acknowledged, do nothing.
// Do nothing if state did not change.
notify := func(ns *conf.Notifications) {
if a.Log {
lastLogTime, ok := s.lastLogTimes[ak]
if ok && lastLogTime.Add(a.MaxLogFrequency).After(time.Now()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about set now := time.Now() to avoid calling it twice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be .Before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LastTime + 5m is next time we can log.

If now is before that we should not log. I think mine is correct but I agree it would make more sense to do now.Before(last + duration)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I was confused. No need to change unless you feel strongly.

@maddyblue
Copy link
Contributor

LGTM

maddyblue added a commit that referenced this pull request Jun 5, 2015
bosun: Ability to throttle log notifications
@maddyblue maddyblue merged commit a4d8d16 into master Jun 5, 2015
@maddyblue maddyblue deleted the maxLogFreq branch June 5, 2015 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants