Update chronograf backend with OpsGenie2

pull/3369/head
Iris Scholten 2018-05-03 11:00:26 -07:00
parent 0d42cf8fc1
commit a54e8c76bd
3 changed files with 18 additions and 0 deletions

View File

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

View File

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

View File

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