|
|
|
@ -41,9 +41,9 @@ type RuleEval struct {
|
|
|
|
|
ctx context.Context
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (re *RuleEval) start() {
|
|
|
|
|
logger.Debugf("[prome_pull_alert_start][RuleEval: %+v]", re)
|
|
|
|
|
go func(re *RuleEval) {
|
|
|
|
|
func (re RuleEval) start() {
|
|
|
|
|
go func(re RuleEval) {
|
|
|
|
|
logger.Debugf("[prome_pull_alert_start][RuleEval: %+v]", re)
|
|
|
|
|
if re.R.PullExpr.EvaluationInterval <= 0 {
|
|
|
|
|
re.R.PullExpr.EvaluationInterval = DEFAULT_PULL_ALERT_INTERVAL
|
|
|
|
|
}
|
|
|
|
@ -72,7 +72,7 @@ func (re *RuleEval) start() {
|
|
|
|
|
}(re)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *RuleEval) stop() {
|
|
|
|
|
func (r RuleEval) stop() {
|
|
|
|
|
logger.Debugf("[prome_pull_alert_stop][RuleEval: %+v]", r)
|
|
|
|
|
close(r.quiteChan)
|
|
|
|
|
}
|
|
|
|
@ -103,17 +103,17 @@ func (rm *RuleManager) SyncRules(ctx context.Context, rules []models.AlertRule)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 停止旧的
|
|
|
|
|
for hash, t := range rm.activeRules {
|
|
|
|
|
for hash := range rm.activeRules {
|
|
|
|
|
if _, loaded := thisAllRules[hash]; !loaded {
|
|
|
|
|
t.stop()
|
|
|
|
|
rm.activeRules[hash].stop()
|
|
|
|
|
delete(rm.activeRules, hash)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rm.targetMtx.Unlock()
|
|
|
|
|
|
|
|
|
|
// 开启新的
|
|
|
|
|
for _, t := range thisNewRules {
|
|
|
|
|
t.start()
|
|
|
|
|
for hash := range thisNewRules {
|
|
|
|
|
thisNewRules[hash].start()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|