From dbbe965dbf2d055a973d67362f73514dacd65b6e Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Mon, 17 Jun 2019 15:23:52 +0200 Subject: [PATCH] Update main.go --- prometheus/main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/prometheus/main.go b/prometheus/main.go index 77ce15b..8df1df4 100644 --- a/prometheus/main.go +++ b/prometheus/main.go @@ -30,17 +30,19 @@ func init() { return } - contentTag := request.Status - if len(request.Alerts.Firing()) > 0 { - contentTag += ":" + len(request.Alerts.Firing()) + 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()," ")) } - content := fmt.Sprintf("[%s] %s", contentTag, strings.Join(request.CommonAnnotations.Values()," ")) + logger = logger.WithField("body", content) ok := false for _, hook := range hooks { - if request.Payload.VCSURL != hook.Secret { + if request.ExternalURL != hook.Secret { continue } logger.Infof("run hook")