fix: recovery duration
This commit is contained in:
parent
45fe14b439
commit
256dceb624
|
@ -8,6 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/src/dataobj"
|
"github.com/didi/nightingale/src/dataobj"
|
||||||
"github.com/didi/nightingale/src/model"
|
"github.com/didi/nightingale/src/model"
|
||||||
|
@ -109,7 +110,7 @@ func Judge(stra *model.Stra, exps []model.Exp, historyData []*dataobj.RRDData, f
|
||||||
Hashid: getHashId(stra.Id, firstItem),
|
Hashid: getHashId(stra.Id, firstItem),
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEventIfNeed(historyData, status, event)
|
sendEventIfNeed(historyData, status, event, stra.RecoveryDur)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -388,7 +389,7 @@ func GetReqs(stra *model.Stra, metric string, endpoints []string, now int64) ([]
|
||||||
return reqs, nil
|
return reqs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendEventIfNeed(historyData []*dataobj.RRDData, status []bool, event *dataobj.Event) {
|
func sendEventIfNeed(historyData []*dataobj.RRDData, status []bool, event *dataobj.Event, recoveryDur int) {
|
||||||
isTriggered := true
|
isTriggered := true
|
||||||
for _, s := range status {
|
for _, s := range status {
|
||||||
isTriggered = isTriggered && s
|
isTriggered = isTriggered && s
|
||||||
|
@ -414,6 +415,11 @@ func sendEventIfNeed(historyData []*dataobj.RRDData, status []bool, event *datao
|
||||||
} else {
|
} else {
|
||||||
// 如果LastEvent是Problem,报OK,否则啥都不做
|
// 如果LastEvent是Problem,报OK,否则啥都不做
|
||||||
if exists && lastEvent.EventType[0] == 'a' {
|
if exists && lastEvent.EventType[0] == 'a' {
|
||||||
|
// 如果配置了留观时长,则距离上一次故障时间要大于等于recoveryDur,才产生恢复事件
|
||||||
|
if time.Now().Unix()-lastEvent.Etime < int64(recoveryDur) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
event.EventType = EVENT_RECOVER
|
event.EventType = EVENT_RECOVER
|
||||||
sendEvent(event)
|
sendEvent(event)
|
||||||
stats.Counter.Set("event.recover", 1)
|
stats.Counter.Set("event.recover", 1)
|
||||||
|
|
Loading…
Reference in New Issue