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

Change alert levels to be independent #732

Merged
merged 1 commit into from
Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
- [#723](https://github.com/influxdata/kapacitor/pull/723): BREAKING: Search for valid configuration on startup in ~/.kapacitor and /etc/kapacitor/.
This is so that the -config CLI flag is not required if the configuration is found in a standard location.
The configuration file being used is always logged to STDERR.
- [#298](https://github.com/influxdata/kapacitor/issue/298): BREAKING: Change alert level evaluation so each level is independent and not required to be a subset of the previous level.
The breaking change is that expression evaluation order changed.
As a result stateful expressions that relied on that order are broken.

## v1.0.0-beta3 [2016-07-09]

Expand Down
19 changes: 9 additions & 10 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,21 +551,20 @@ func (a *AlertNode) handleAlert(ad *AlertData) {
}
}

func (a *AlertNode) determineLevel(now time.Time, fields models.Fields, tags map[string]string) (level AlertLevel) {
for l, se := range a.levels {
func (a *AlertNode) determineLevel(now time.Time, fields models.Fields, tags map[string]string) AlertLevel {
for l := len(a.levels) - 1; l >= 0; l-- {
se := a.levels[l]
if se == nil {
continue
}
if pass, err := EvalPredicate(se, a.scopePools[l], now, fields, tags); pass {
level = AlertLevel(l)
} else if err != nil {
a.logger.Println("E! error evaluating expression:", err)
return
} else {
return
if pass, err := EvalPredicate(se, a.scopePools[l], now, fields, tags); err != nil {
a.logger.Printf("E! error evaluating expression for level %v: %s", AlertLevel(l), err)
continue
} else if pass {
return AlertLevel(l)
}
}
return
return OKAlert
}

func (a *AlertNode) batchToResult(b models.Batch) influxql.Result {
Expand Down
9 changes: 3 additions & 6 deletions pipeline/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,10 @@ const defaultLogFileMode = 0600
// .email().to('oncall@example.com')
//
//
// It is assumed that each successive level filters a subset
// of the previous level. As a result, the filter will only be applied if
// a data point passed the previous level.
// In the above example, if value = 15 then the INFO and
// WARNING expressions would be evaluated, but not the
// CRITICAL expression.
// Each expression maintains its own state.
// The order of execution for the expressions is not considered to be deterministic.
// For each point an expression may or may not be evaluated.
// If no expression is true then the alert is considered to be in the OK state.
//
// Available Statistics:
//
Expand Down