fix mute bug (#1025)

Co-authored-by: tripitakav <chengzhi.shang@longbridge.sg>
This commit is contained in:
Tripitakav 2022-07-07 10:05:39 +08:00 committed by GitHub
parent fe82886f09
commit 18a9288b75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -30,8 +30,9 @@ func matchMute(event *models.AlertCurEvent, mute *models.AlertMute, clock ...int
if ts < mute.Btime || ts > mute.Etime { if ts < mute.Btime || ts > mute.Etime {
return false return false
} }
tg := event.TagsMap
return matchTags(event.TagsMap, mute.ITags) tg["alertname"] = event.RuleName
return matchTags(tg, mute.ITags)
} }
func matchTags(eventTagsMap map[string]string, itags []models.TagFilter) bool { func matchTags(eventTagsMap map[string]string, itags []models.TagFilter) bool {

View File

@ -314,6 +314,7 @@ func (r RuleEval) judge(vectors []conv.Vector) {
TriggerTime: vectors[i].Timestamp, TriggerTime: vectors[i].Timestamp,
TagsMap: tagsMap, TagsMap: tagsMap,
GroupId: r.rule.GroupId, GroupId: r.rule.GroupId,
RuleName: r.rule.Name,
} }
bg := memsto.BusiGroupCache.GetByBusiGroupId(r.rule.GroupId) bg := memsto.BusiGroupCache.GetByBusiGroupId(r.rule.GroupId)
@ -321,7 +322,7 @@ func (r RuleEval) judge(vectors []conv.Vector) {
event.GroupName = bg.Name event.GroupName = bg.Name
} }
// isMuted only need TriggerTime and TagsMap // isMuted only need TriggerTime RuleName and TagsMap
if isMuted(event) { if isMuted(event) {
logger.Infof("event_muted: rule_id=%d %s", r.rule.Id, vectors[i].Key) logger.Infof("event_muted: rule_id=%d %s", r.rule.Id, vectors[i].Key)
continue continue