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.
This commit is contained in:
Brian Brazil 2015-12-07 16:55:37 +00:00
parent 7ddcc42efa
commit 29fd91784b

View File

@ -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,
}