fix: 自定义指标数据计算小于0就强制为0

This commit is contained in:
TsMask
2025-07-23 10:57:51 +08:00
parent be5f929f1f
commit 0b4f04c33c

View File

@@ -183,11 +183,14 @@ func (s *KPI) saveKPIDataC(k oam.KPI, index int64) error {
item["err"] = err.Error() item["err"] = err.Error()
} else { } else {
if v.Unit == "%" { if v.Unit == "%" {
resultInt64 := parse.Number(result) resultV, ok := result.(float64)
if resultInt64 > 100 { if !ok {
resultV = 0
}
if resultV > 100 {
result = 100 result = 100
} }
if resultInt64 < 0 { if resultV < 0 {
result = 0 result = 0
} }
} }