adapter old alert rule data struct

This commit is contained in:
liugq 2023-07-28 17:06:07 +08:00
parent ce98378a7c
commit d42c05c8fb
1 changed files with 8 additions and 0 deletions

View File

@ -135,6 +135,14 @@ func (alertAPI *AlertAPI) getRule(w http.ResponseWriter, req *http.Request, ps h
alertAPI.WriteError(w, err.Error(), http.StatusInternalServerError)
return
}
// adapter version smaller than 1.6.0
if obj.Channels != nil && obj.NotificationConfig == nil {
obj.NotificationConfig = obj.Channels
}
if obj.NotificationConfig != nil && obj.NotificationConfig.Message == "" && obj.Metrics.Message != "" {
obj.NotificationConfig.Message = obj.Metrics.Message
obj.NotificationConfig.Title = obj.Metrics.Title
}
alertAPI.WriteJSON(w, util.MapStr{
"found": true,