perf(logs): 修 label 下拉 20 秒、Loki CPU 限流 76%、告警检查频率
CI / Backend (go vet + test) (push) Canceled after 0s
CI / Frontend (lint + build + test) (push) Canceled after 0s

1) Loki CPU 限流 76%(limits 4 核,实测 3923m,nr_throttled 920656/1209379)
   → limits 提到 8 核 / requests 2 核。限流归零,histogram 84ms,
     by-app 从 60s 超时降到 14.9s。
2) label values 未传时间范围 → Loki 默认扫 6 小时索引(370GB/天 → 10~21s)
   → 默认只查最近 1 小时。实测 namespace 21330ms→33ms,app 24781ms→30ms。
3) max_query_parallelism 8 > 实际核数 → 调到 6。
4) 告警检查 1 分钟 → 5 分钟(规则窗口本身 15 分钟,稳态负载降到 1/5)。
This commit is contained in:
opsx committed 2026-10-30 03:42:03 +00:00
1 parent 7624baa564
commit c9e604b35f
3 files changed
+20 -2

No files matched your search

+4 -1
View File
@@ -48,7 +48,10 @@ func overStormLimit() (bool, int) {
return sent >= alertStormMaxPerHour, sent
}
const alertCheckInterval = time.Minute
// 检查间隔:规则窗口都是 15 分钟,1 分钟查一次等于用 15 倍频率扫同样的数据。
// Loki 单实例 CPU 是瓶颈(实测被限流 76%),这里降到 5 分钟:
// 对告警及时性影响很小(窗口本身就是 15 分钟),但稳态负载降到 1/5。
const alertCheckInterval = 5 * time.Minute
const (
// alertRoundTimeout 一轮检查的总时限。超过就中断本轮,