refactor fireEvent
This commit is contained in:
parent
218140066b
commit
1ea8694769
|
@ -288,24 +288,8 @@ func labelMapToArr(m map[string]string) []string {
|
|||
}
|
||||
|
||||
func (r RuleEval) handleNewEvent(event *models.AlertCurEvent) {
|
||||
if fired, has := r.fires[event.Hash]; has {
|
||||
if r.rule.NotifyRepeatStep == 0 {
|
||||
// 说明不想重复通知,那就直接返回了,nothing to do
|
||||
return
|
||||
}
|
||||
|
||||
// 之前发送过告警了,这次是否要继续发送,要看是否过了通道静默时间
|
||||
if event.LastEvalTime > fired.LastEvalTime+int64(r.rule.NotifyRepeatStep)*60 {
|
||||
r.fires[event.Hash] = event
|
||||
pushEventToQueue(event)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if event.PromForDuration == 0 {
|
||||
r.fires[event.Hash] = event
|
||||
pushEventToQueue(event)
|
||||
r.fireEvent(event)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -317,6 +301,23 @@ func (r RuleEval) handleNewEvent(event *models.AlertCurEvent) {
|
|||
}
|
||||
|
||||
if r.pendings[event.Hash].LastEvalTime-r.pendings[event.Hash].TriggerTime > int64(event.PromForDuration) {
|
||||
r.fireEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
func (r RuleEval) fireEvent(event *models.AlertCurEvent) {
|
||||
if fired, has := r.fires[event.Hash]; has {
|
||||
if r.rule.NotifyRepeatStep == 0 {
|
||||
// 说明不想重复通知,那就直接返回了,nothing to do
|
||||
return
|
||||
}
|
||||
|
||||
// 之前发送过告警了,这次是否要继续发送,要看是否过了通道静默时间
|
||||
if event.LastEvalTime > fired.LastEvalTime+int64(r.rule.NotifyRepeatStep)*60 {
|
||||
r.fires[event.Hash] = event
|
||||
pushEventToQueue(event)
|
||||
}
|
||||
} else {
|
||||
r.fires[event.Hash] = event
|
||||
pushEventToQueue(event)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue