Update prometheus/main.go
This commit is contained in:
parent
73c9b9fb77
commit
23c2eb44eb
|
@ -24,22 +24,21 @@ func init() {
|
||||||
logger := log.WithField("type", hookType)
|
logger := log.WithField("type", hookType)
|
||||||
|
|
||||||
var request notify.WebhookMessage
|
var request notify.WebhookMessage
|
||||||
if err := libHTTP.Read(r, &request); err != nil {
|
if err := libHTTP.Read(r, &request); err != nil {
|
||||||
logger.Errorf("no readable payload: %s", err)
|
logger.Errorf("no readable payload: %s", err)
|
||||||
http.Error(w, fmt.Sprintf("no readable payload"), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("no readable payload"), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
content := ""
|
content := ""
|
||||||
firingAlerts := len(request.Alerts.Firing())
|
firingAlerts := len(request.Alerts.Firing())
|
||||||
if firingAlerts > 0 {
|
if firingAlerts > 0 {
|
||||||
content = fmt.Sprintf("[%s:%d] %s", request.Status, firingAlerts, strings.Join(request.CommonAnnotations.Values()," "))
|
content = fmt.Sprintf("[%s:%d] %s", request.Status, firingAlerts, strings.Join(request.CommonAnnotations.Values()," "))
|
||||||
} else {
|
} else {
|
||||||
content = fmt.Sprintf("[%s] %s", request.Status, strings.Join(request.CommonAnnotations.Values()," "))
|
content = fmt.Sprintf("[%s] %s", request.Status, strings.Join(request.CommonAnnotations.Values()," "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger = logger.WithField("body", content)
|
||||||
logger = logger.WithField("body", content)
|
|
||||||
|
|
||||||
ok := false
|
ok := false
|
||||||
for _, hook := range hooks {
|
for _, hook := range hooks {
|
||||||
|
|
Loading…
Reference in New Issue