Update main.go

This commit is contained in:
Martin/Geno 2019-06-17 15:28:52 +02:00
parent dbbe965dbf
commit 73c9b9fb77
1 changed files with 14 additions and 13 deletions

View File

@ -24,21 +24,22 @@ func init() {
logger := log.WithField("type", hookType)
var request notify.WebhookMessage
if err := libHTTP.Read(r, &request); err != nil {
logger.Errorf("no readable payload: %s", err)
http.Error(w, fmt.Sprintf("no readable payload"), http.StatusInternalServerError)
return
}
firingAlerts := len(request.Alerts.Firing())
if firingAlerts > 0 {
content := fmt.Sprintf("[%s:%d] %s", request.Status, firingAlerts, strings.Join(request.CommonAnnotations.Values()," "))
} else {
content := fmt.Sprintf("[%s] %s", request.Status, strings.Join(request.CommonAnnotations.Values()," "))
}
if err := libHTTP.Read(r, &request); err != nil {
logger.Errorf("no readable payload: %s", err)
http.Error(w, fmt.Sprintf("no readable payload"), http.StatusInternalServerError)
return
}
content := ""
firingAlerts := len(request.Alerts.Firing())
if firingAlerts > 0 {
content = fmt.Sprintf("[%s:%d] %s", request.Status, firingAlerts, strings.Join(request.CommonAnnotations.Values()," "))
} else {
content = fmt.Sprintf("[%s] %s", request.Status, strings.Join(request.CommonAnnotations.Values()," "))
}
logger = logger.WithField("body", content)
logger = logger.WithField("body", content)
ok := false
for _, hook := range hooks {