Skip to content

docs: 历史指标每行新增峰值网速 - #29

Merged
stqfdyr merged 2 commits into
mainfrom
feat/net-peak
Sep 29, 2026
Merged

stqfdyr merged 2 commits into
mainfrom
feat/net-peak

Conversation

@stqfdyr

@stqfdyr stqfdyr commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

主题开发页说明 /api/nodes/{id}/metrics 每行新增的 net_rx_max / net_tx_max:这段时间内按上报间隔测得的最高网速,不小于平均值,hub 1.3.0 及更早没有。架构页写明历史行另存每分钟的峰值,聚合成宽窗口时取桶内最大值。

对应 monitor-probe/monitor#68

stqfdyr added a commit to monitor-probe/monitor that referenced this pull request Sep 27, 2026
历史图的网速是每分钟的平均值,积分等于累计流量,但一次 15 秒的测速会被摊到整分钟:实测 286 Mbit/s 的突发,分钟行记 72.2 Mbit/s,7 天窗口里只剩 8–10 Mbit/s。

- 每分钟的历史行另存这一分钟 agent 上报过的最高网速(`net_rx_max` / `net_tx_max`),随同一条 INSERT 写入,不多一次提交。schema 升到 10,两列默认 0,回退到旧版 hub 照常写入
- 峰值取 agent 按上报间隔测得的速率,不由 hub 按两帧的到达间隔推算:网络把帧挤在一起时,后者会记下成倍的假峰值
- `/api/nodes/{id}/metrics` 每行多这两个字段。聚合成宽窗口时取桶内最大值,且不低于这一行的平均值,所以升级前没有峰值的行按平均值读
- 分钟平均网速按小数秒计算:按整秒计时会截掉不足一秒的部分,平均值最多偏高 1.7%
- 存储:每行多约 7 B(+15%),每节点每 7 天约 70 KiB

## 测试

- `cargo fmt --check`、`cargo clippy --all-targets`、`cargo test`(126 个)通过
- 用例:一分钟里的突发峰值落库、平均值不变;一个桶的峰值取最大而不是平均,没有峰值的旧行按平均值算。跨 59.5 秒的一分钟按 59.5 秒算平均值。去掉迁移、去掉读取侧对平均值的兜底、改回整秒,对应用例失败
- 预览环境实测:agent 只统计一对 veth(`tc` 限速下行 300、上行 100 Mbit/s),同一分钟里跑 15 秒下行、15 秒上行。实时最高 287.8 / 96.2 Mbit/s,落库峰值 287.9 / 96.5,平均值仍是 72.2 / 25.0;1 小时到 7 天四个窗口的峰值一致;预览库从 schema 9 迁移正常

主题:monitor-probe/monitor-theme-default#15、monitor-probe/monitor-theme-serverstatus#15;文档:monitor-probe/monitor-document#29
@stqfdyr
stqfdyr merged commit 461bcf1 into main Sep 29, 2026
1 check passed
@stqfdyr
stqfdyr deleted the feat/net-peak branch September 29, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant