diff --git a/kapacitor.go b/kapacitor.go index 3d03b73cb..c5c3cc3ce 100644 --- a/kapacitor.go +++ b/kapacitor.go @@ -21,6 +21,7 @@ type AlertNodes struct { HipChat []*HipChat `json:"hipChat"` // HipChat will send alert to all HipChat Alerta []*Alerta `json:"alerta"` // Alerta will send alert to all Alerta OpsGenie []*OpsGenie `json:"opsGenie"` // OpsGenie will send alert to all OpsGenie + OpsGenie2 []*OpsGenie `json:"opsGenie2"` // OpsGenie2 will send alert to all OpsGenie v2 Talk []*Talk `json:"talk"` // Talk will send alert to all Talk } diff --git a/server/kapacitors.go b/server/kapacitors.go index fd6940d9b..a528ba894 100644 --- a/server/kapacitors.go +++ b/server/kapacitors.go @@ -429,6 +429,22 @@ func newAlertResponse(task *kapa.Task, srcID, kapaID int) *alertResponse { } } + if res.AlertNodes.OpsGenie2 == nil { + res.AlertNodes.OpsGenie2 = []*chronograf.OpsGenie{} + } + + for i, a := range res.AlertNodes.OpsGenie2 { + if a.Teams == nil { + a.Teams = []string{} + res.AlertNodes.OpsGenie2[i] = a + } + + if a.Recipients == nil { + a.Recipients = []string{} + res.AlertNodes.OpsGenie2[i] = a + } + } + if res.AlertNodes.PagerDuty == nil { res.AlertNodes.PagerDuty = []*chronograf.PagerDuty{} } diff --git a/server/kapacitors_test.go b/server/kapacitors_test.go index 9eb114612..f528a540a 100644 --- a/server/kapacitors_test.go +++ b/server/kapacitors_test.go @@ -130,6 +130,7 @@ func Test_KapacitorRulesGet(t *testing.T) { HipChat: []*chronograf.HipChat{}, Alerta: []*chronograf.Alerta{}, OpsGenie: []*chronograf.OpsGenie{}, + OpsGenie2: []*chronograf.OpsGenie{}, Talk: []*chronograf.Talk{}, }, },