Merge branch 'main' of github.com:ccfos/nightingale

This commit is contained in:
Ulric Qin 2022-07-26 15:54:42 +08:00
commit 39705787c9
3 changed files with 9 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import (
) )
// 如果传入了clock这个可选参数就表示使用这个clock表示的时间否则就从event的字段中取TriggerTime // 如果传入了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) mutes, has := memsto.AlertMuteCache.Gets(event.GroupId)
if !has || len(mutes) == 0 { if !has || len(mutes) == 0 {
return false return false

View File

@ -324,7 +324,7 @@ func (r RuleEval) judge(vectors []conv.Vector) {
} }
// isMuted only need TriggerTime RuleName 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
} }

View File

@ -36,6 +36,13 @@ func pushEventToQueue(c *gin.Context) {
event.TagsMap[arr[0]] = arr[1] 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 { if err := event.ParseRuleNote(); err != nil {
event.RuleNote = fmt.Sprintf("failed to parse rule note: %v", err) event.RuleNote = fmt.Sprintf("failed to parse rule note: %v", err)
} }