Files
iAOP/deploy/k8s/healthz/README.md
T

56 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 可用性监控探针(Availability Probe)
对应 EPIC #8「⑥ 部署底座」子任务 **#61**(0.5d,对齐 PRD 5.6 验收):
对已部署服务按周期轮询健康端点(`GET /health`),统计窗口可用率,
目标 **≥ 99.8%**。
## 文件
```
deploy/k8s/healthz/
├── probe_availability.py 探针实现(AvailabilityProbe + CLI)
├── test_probe.py 单元测试(本地 HTTP 端点模拟)
└── README.md
```
## 用法(CLI)
```bash
# 轮询 60 轮(每 1s 一次),目标 99.8%
python probe_availability.py --endpoints http://10.20.0.30:8000 \
--rounds 60 --interval 1 --target 0.998
# 多端点
python probe_availability.py --endpoints http://a:8000,http://b:8000 \
--rounds 120 --interval 5
```
退出码:`0` = 可用率达标(PASS);`1` = 低于目标(FAIL),
供 CronJob / 监控告警使用。
## 编程接口
```python
from probe_availability import AvailabilityProbe
probe = AvailabilityProbe(["http://iaop-inference:8000"])
report = probe.run(rounds=60, interval=1)
print(report.to_dict())
# {'total': 60, 'success': 60, 'availability': 1.0,
# 'target': 0.998, 'meets_target': True, 'failures': 0, ...}
```
## 验收口径(PRD 5.6)
- 可用率 = 成功探测数 / 总探测数,窗口内 ≥ 99.8%;
- 探针**只读**(GET /health),不影响服务状态;
- 失败明细(URL/原因/延迟)随报告输出,便于定位。
## 测试
```bash
python -m unittest test_probe -v
```
覆盖:稳定端点 100% 达标、单次故障(1/500=0.2%)恰好达标、
50% 故障率判定 FAIL、失败明细记录。