From 52b3afbd9709cc5ed75da46ca56ae48755fa1583 Mon Sep 17 00:00:00 2001 From: 710leo <710leo@gmail.com> Date: Sun, 22 Sep 2024 19:14:24 +0800 Subject: [PATCH] fix: recovery event tags map split --- alert/process/process.go | 5 +++++ alert/router/router_event.go | 2 +- alert/sender/ibex.go | 2 +- center/router/router_alert_rule.go | 2 +- center/router/router_notify_tpl.go | 2 +- models/alert_cur_event.go | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/alert/process/process.go b/alert/process/process.go index f68021c3..9b154409 100644 --- a/alert/process/process.go +++ b/alert/process/process.go @@ -527,6 +527,11 @@ func (p *Processor) RecoverAlertCurEventFromDb() { } event.DB2Mem() + target, exists := p.TargetCache.Get(event.TargetIdent) + if exists { + event.Target = target + } + fireMap[event.Hash] = event e := *event pendingsUseByRecoverMap[event.Hash] = &e diff --git a/alert/router/router_event.go b/alert/router/router_event.go index 0c23d94a..9e3bde2d 100644 --- a/alert/router/router_event.go +++ b/alert/router/router_event.go @@ -34,7 +34,7 @@ func (rt *Router) pushEventToQueue(c *gin.Context) { continue } - arr := strings.Split(pair, "=") + arr := strings.SplitN(pair, "=", 2) if len(arr) != 2 { continue } diff --git a/alert/sender/ibex.go b/alert/sender/ibex.go index d0e5301b..0c26a261 100644 --- a/alert/sender/ibex.go +++ b/alert/sender/ibex.go @@ -108,7 +108,7 @@ func CallIbex(ctx *ctx.Context, id int64, host string, continue } - arr := strings.Split(pair, "=") + arr := strings.SplitN(pair, "=", 2) if len(arr) != 2 { continue } diff --git a/center/router/router_alert_rule.go b/center/router/router_alert_rule.go index 942f78e5..64c41004 100644 --- a/center/router/router_alert_rule.go +++ b/center/router/router_alert_rule.go @@ -514,7 +514,7 @@ func (rt *Router) relabelTest(c *gin.Context) { labels := make([]prompb.Label, len(f.Tags)) for i, tag := range f.Tags { - label := strings.Split(tag, "=") + label := strings.SplitN(tag, "=", 2) if len(label) != 2 { ginx.Bomb(http.StatusBadRequest, "tag:%s format error", tag) } diff --git a/center/router/router_notify_tpl.go b/center/router/router_notify_tpl.go index b9eaedde..4fa7606b 100644 --- a/center/router/router_notify_tpl.go +++ b/center/router/router_notify_tpl.go @@ -138,7 +138,7 @@ func (rt *Router) notifyTplPreview(c *gin.Context) { continue } - arr := strings.Split(pair, "=") + arr := strings.SplitN(pair, "=", 2) if len(arr) != 2 { continue } diff --git a/models/alert_cur_event.go b/models/alert_cur_event.go index ad05b3ea..583763a1 100644 --- a/models/alert_cur_event.go +++ b/models/alert_cur_event.go @@ -342,7 +342,7 @@ func (e *AlertCurEvent) DB2Mem() { continue } - arr := strings.Split(pair, "=") + arr := strings.SplitN(pair, "=", 2) if len(arr) != 2 { continue }