Add more config validation

Validates that all alerts are actually found in the alert list
This commit is contained in:
Ian Fijolek
2019-10-07 10:48:19 -07:00
parent 1b07059825
commit 351216c3a7
4 changed files with 31 additions and 4 deletions
+5 -4
View File
@@ -27,7 +27,7 @@ func checkMonitors(config *Config) error {
}
alertNames := monitor.GetAlertNames(alertNotice.IsUp)
if alertNames == nil {
// TODO: Should this be a panic? Should this be validated against? Probably
// This should only happen for a recovery alert. AlertDown is validated not empty
log.Printf(
"WARNING: Recieved alert, but no alert mechanisms exist. MonitorName=%s IsUp=%t",
alertNotice.MonitorName, alertNotice.IsUp,
@@ -44,15 +44,16 @@ func checkMonitors(config *Config) error {
output,
)
return fmt.Errorf(
"ERROR: Unsuccessfully triggered alert '%s'. "+
"Unsuccessfully triggered alert '%s'. "+
"Crashing to avoid false negatives: %v",
alert.Name,
err,
)
}
} else {
// TODO: Maybe panic here. Also, probably validate up front
log.Printf("ERROR: Alert with name '%s' not found", alertName)
// This case should never actually happen since we validate against it
log.Printf("ERROR: Unknown alert for monitor %s: %s", alertNotice.MonitorName, alertName)
return fmt.Errorf("Unknown alert for monitor %s: %s", alertNotice.MonitorName, alertName)
}
}
}