Skip to content

Commit

Permalink
Handle errors when checking for first match level
Browse files Browse the repository at this point in the history
  • Loading branch information
Minh Danh committed Aug 5, 2016
1 parent f254d50 commit 0b9bf42
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,9 @@ func (a *AlertNode) handleAlert(ad *AlertData) {
}

func (a *AlertNode) determineLevel(now time.Time, fields models.Fields, tags map[string]string, currentLevel AlertLevel) AlertLevel {
if higherLevel, err := a.findFirstMatchLevel(CritAlert, currentLevel-1, now, fields, tags); err == nil {
if higherLevel, err := a.findFirstMatchLevel(CritAlert, currentLevel-1, now, fields, tags); err != nil {
a.logger.Printf("D! find first match level from %s to %s: %s", CritAlert, currentLevel-1, err)
} else {
return higherLevel
}
if rse := a.levelResets[currentLevel]; rse != nil {
Expand All @@ -601,7 +603,9 @@ func (a *AlertNode) determineLevel(now time.Time, fields models.Fields, tags map
return currentLevel
}
}
if newLevel, err := a.findFirstMatchLevel(currentLevel-1, OKAlert, now, fields, tags); err == nil {
if newLevel, err := a.findFirstMatchLevel(currentLevel, OKAlert, now, fields, tags); err != nil {
a.logger.Printf("D! find first match level from %s to %s: %s", currentLevel, OKAlert, err)
} else {
return newLevel
}
return OKAlert
Expand All @@ -623,7 +627,7 @@ func (a *AlertNode) findFirstMatchLevel(start AlertLevel, stop AlertLevel, now t
return AlertLevel(l), nil
}
}
return OKAlert, errors.New("No match found")
return OKAlert, errors.New("no match found")
}

func (a *AlertNode) batchToResult(b models.Batch) influxql.Result {
Expand Down

0 comments on commit 0b9bf42

Please sign in to comment.