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
+12
View File
@@ -29,6 +29,18 @@ func (config Config) IsValid() (isValid bool) {
log.Printf("ERROR: Invalid monitor configuration: %s", monitor.Name)
isValid = false
}
// Check that all Monitor alerts actually exist
for _, isUp := range []bool{true, false} {
for _, alertName := range monitor.GetAlertNames(isUp) {
if _, ok := config.Alerts[alertName]; !ok {
log.Printf(
"ERROR: Invalid monitor configuration: %s. Unknown alert %s",
monitor.Name, alertName,
)
isValid = false
}
}
}
}
// Validate alerts