Add a default log alert

This commit is contained in:
Ian Fijolek
2020-02-18 00:47:43 +00:00
parent a7d1b8ab74
commit 65342fe0dd
2 changed files with 18 additions and 0 deletions
+13
View File
@@ -112,3 +112,16 @@ func (alert Alert) Send(notice AlertNotice) (outputStr string, err error) {
return outputStr, err
}
// NewLogAlert creates an alert that does basic logging using echo
func NewLogAlert() *Alert {
return &Alert{
Name: "log",
Command: CommandOrShell{
Command: []string{
"echo",
"{{.MonitorName}} check has failed {{.FailureCount}} times",
},
},
}
}
+5
View File
@@ -117,6 +117,11 @@ func LoadConfig(filePath string) (config Config, err error) {
log.Printf("DEBUG: Config values:\n%v\n", config)
}
if _, ok := config.Alerts["log"]; !ok {
log.Printf("Adding log alert")
config.Alerts["log"] = NewLogAlert()
}
if !config.IsValid() {
err = errors.New("Invalid configuration")
return