From 95ab2f649db19087caa678de4aa0ef207cce483c Mon Sep 17 00:00:00 2001 From: tripitakav Date: Wed, 6 Jul 2022 17:42:31 +0800 Subject: [PATCH] fix mute bug --- src/server/engine/mute.go | 5 +++-- src/server/engine/worker.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/server/engine/mute.go b/src/server/engine/mute.go index 9dc1208bc..649907850 100644 --- a/src/server/engine/mute.go +++ b/src/server/engine/mute.go @@ -30,8 +30,9 @@ func matchMute(event *models.AlertCurEvent, mute *models.AlertMute, clock ...int if ts < mute.Btime || ts > mute.Etime { return false } - - return matchTags(event.TagsMap, mute.ITags) + tg := event.TagsMap + tg["alertname"] = event.RuleName + return matchTags(tg, mute.ITags) } func matchTags(eventTagsMap map[string]string, itags []models.TagFilter) bool { diff --git a/src/server/engine/worker.go b/src/server/engine/worker.go index 99b3219d3..ba93c2444 100644 --- a/src/server/engine/worker.go +++ b/src/server/engine/worker.go @@ -314,6 +314,7 @@ func (r RuleEval) judge(vectors []conv.Vector) { TriggerTime: vectors[i].Timestamp, TagsMap: tagsMap, GroupId: r.rule.GroupId, + RuleName: r.rule.Name, } bg := memsto.BusiGroupCache.GetByBusiGroupId(r.rule.GroupId) @@ -321,7 +322,7 @@ func (r RuleEval) judge(vectors []conv.Vector) { event.GroupName = bg.Name } - // isMuted only need TriggerTime and TagsMap + // isMuted only need TriggerTime RuleName and TagsMap if isMuted(event) { logger.Infof("event_muted: rule_id=%d %s", r.rule.Id, vectors[i].Key) continue