Add a default log alert
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
IamTheFij 2020-02-18 00:47:43 +00:00
parent a7d1b8ab74
commit 65342fe0dd
2 changed files with 18 additions and 0 deletions

View File

@ -112,3 +112,16 @@ func (alert Alert) Send(notice AlertNotice) (outputStr string, err error) {
return outputStr, err 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",
},
},
}
}

View File

@ -117,6 +117,11 @@ func LoadConfig(filePath string) (config Config, err error) {
log.Printf("DEBUG: Config values:\n%v\n", config) 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() { if !config.IsValid() {
err = errors.New("Invalid configuration") err = errors.New("Invalid configuration")
return return