From 29fd91784b3f8b27d21d840a1f54b9b38de08d30 Mon Sep 17 00:00:00 2001 From: Brian Brazil Date: Mon, 7 Dec 2015 16:55:37 +0000 Subject: [PATCH] Update webhook for new alertmanager. As we've a new data format the version number needs a bump. Also make alerts with no annotations easier to handle for users on the receiving end. --- notify/impl.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/notify/impl.go b/notify/impl.go index 6d487d9d..2e69d82a 100644 --- a/notify/impl.go +++ b/notify/impl.go @@ -96,8 +96,16 @@ type WebhookMessage struct { func (w *Webhook) Notify(ctx context.Context, alerts ...*types.Alert) error { as := types.Alerts(alerts...) + // If there are no annotations, instantiate so + // {} is sent rather than null. + for _, a := range as { + if a.Annotations == nil { + a.Annotations = model.LabelSet{} + } + } + msg := &WebhookMessage{ - Version: "1", + Version: "2", Status: as.Status(), Alerts: as, }