docs(runbook): storage budgets and retention runbook (CACHE-2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-29 17:16:50 +08:00
1 parent 71d2cd70cf
commit 4f7c0a62c2
6 files changed
+179 -13

No files matched your search

+6 -2
View File
@@ -14,7 +14,8 @@
- 每 15 秒 upsert `process_heartbeat` 一行,同时往 `process_heartbeat_sample` 追加一条采样。
- 行主键 `instance_id = <kind>:<host>:<pid>`,容器重启覆盖同一行。
- 正常退出(SIGTERM / SIGINT)时写入器把本行标 `stopped_at`,读取方立即归入已下线实例;重启后同一行的 upsert 把它清回 null。
- 裁剪由定时任务 `system.heartbeat_cleanup`(维护组,1 小时)负责:24 小时没心跳的进程行删除,采样保留 7 天。
- 裁剪由定时任务 `system.heartbeat_cleanup`(维护组,1 小时)负责:24 小时没心跳的进程行删除,采样保留
`storage.retentionDays.heartbeatHours`(缺省 24 小时,CACHE-2 前是 7 天)。
- 写库失败只记 debug 日志,不影响业务。
## GET /system/health 字段
@@ -40,12 +41,13 @@
| `mounts[]` | 库根做哨兵检查(`checkRoot`),下载目录只查目录可读。`status`:`online` / `offline` / `timeout` |
| `engine` | 待处理 run 数、执行中 run 数、最老待处理时长、24 小时结束数 / 失败数 / 失败率 |
| `schedules` | 定时任务总数、启用数、执行中数、最近一次失败的启用任务、24 小时失败运行数 |
| `storage` | 存储预算档位与告警文案(PG 库体积、图片缓存、备份、会话与证据对照 `settings.storage.budgets`),明细见 `GET /system/storage`([storage.md](storage.md)) |
单个路径的 statfs 或哨兵检查超过 3 秒记 `timeout`:磁盘段标 critical,挂载段标 `timeout`。请求本身不会被卡住。
## GET /system/health/history?hours=
- `hours` 取 1–168,缺省 6。
- `hours` 取 1–168,缺省 6。采样只保留 `heartbeatHours`(缺省 24 小时),更早的部分为空。
- 按桶聚合,每条序列最多约 360 个点。桶宽最小 15 秒,168 小时时是 1680 秒。
- 每个进程一条序列,每个点有 `lagMs`(桶内平均)、`lagMaxMs`(桶内最大)、`runningRuns`、`sseConnections`。
@@ -61,6 +63,8 @@
- 最老待处理 run 等待 ≥ 5 分钟记 warn,≥ 30 分钟记 critical。通常是 worker 没起来或并发被占满。
- 24 小时失败率 ≥ 10% 记 warn;失败率 ≥ 30% 且结束数 ≥ 10 记 critical。
- 有启用的定时任务最近一次运行失败:warn。
- PG 库体积 ≥ `pgDataWarnGb`(20 GB)记 warn,≥ `pgDataGb`(25 GB)记 critical;备份、会话与证据 ≥ 预算 80% 记 warn、≥ 预算记 critical;
图片缓存超预算 10% 记 warn。
## 引擎 runs 的业务字段