diff --git a/src/server/engine/mute.go b/src/server/engine/mute.go index 75149cd1..7ddc43f1 100644 --- a/src/server/engine/mute.go +++ b/src/server/engine/mute.go @@ -6,7 +6,7 @@ import ( ) // 如果传入了clock这个可选参数,就表示使用这个clock表示的时间,否则就从event的字段中取TriggerTime -func isMuted(event *models.AlertCurEvent, clock ...int64) bool { +func IsMuted(event *models.AlertCurEvent, clock ...int64) bool { mutes, has := memsto.AlertMuteCache.Gets(event.GroupId) if !has || len(mutes) == 0 { return false diff --git a/src/server/engine/worker.go b/src/server/engine/worker.go index 6f254a78..d54e0984 100644 --- a/src/server/engine/worker.go +++ b/src/server/engine/worker.go @@ -324,7 +324,7 @@ func (r RuleEval) judge(vectors []conv.Vector) { } // 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) continue } diff --git a/src/server/router/router_event.go b/src/server/router/router_event.go index 969ae971..b3c5c168 100644 --- a/src/server/router/router_event.go +++ b/src/server/router/router_event.go @@ -36,6 +36,13 @@ func pushEventToQueue(c *gin.Context) { event.TagsMap[arr[0]] = arr[1] } + // isMuted only need TriggerTime RuleName and TagsMap + if engine.IsMuted(event) { + logger.Infof("event_muted: rule_id=%d %s", event.RuleId, event.Hash) + ginx.NewRender(c).Message(nil) + return + } + if err := event.ParseRuleNote(); err != nil { event.RuleNote = fmt.Sprintf("failed to parse rule note: %v", err) }