Repository navigation
docs: 历史指标每行新增峰值网速 - #29
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
主题开发页说明
/api/nodes/{id}/metrics每行新增的net_rx_max/net_tx_max:这段时间内按上报间隔测得的最高网速,不小于平均值,hub 1.3.0 及更早没有。架构页写明历史行另存每分钟的峰值,聚合成宽窗口时取桶内最大值。对应 monitor-probe/monitor#68