From d42c05c8fba33592a0a4da7d0608d4e32e647615 Mon Sep 17 00:00:00 2001 From: liugq Date: Fri, 28 Jul 2023 17:06:07 +0800 Subject: [PATCH] adapter old alert rule data struct --- plugin/api/alerting/rule.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin/api/alerting/rule.go b/plugin/api/alerting/rule.go index 6afa8d15..b0a260c5 100644 --- a/plugin/api/alerting/rule.go +++ b/plugin/api/alerting/rule.go @@ -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,