small improvements (#958)

* small improvements

* fix: return empty iterator if no json present

* use time.Tick

* changes
This commit is contained in:
UUBulb
2025-01-19 21:22:00 +08:00
committed by GitHub
parent 844865e2c1
commit 4b1af369e3
10 changed files with 34 additions and 34 deletions

View File

@@ -102,7 +102,7 @@ func (r *AlertRule) Check(points [][]bool) (maxDuration int, passed bool) {
hasPassedRule = true
continue
}
total, fail := 0.0, 0.0
total, fail := 0, 0
for timeTick := len(points) - duration; timeTick < len(points); timeTick++ {
total++
if !points[timeTick][ruleId] {
@@ -110,7 +110,7 @@ func (r *AlertRule) Check(points [][]bool) (maxDuration int, passed bool) {
}
}
// 当70%以上的采样点未通过规则判断时 才认为当前检查未通过
if fail/total <= 0.7 {
if fail*100/total <= 70 {
hasPassedRule = true
}
}