feat(observability): suppress successful health logs

This commit is contained in:
2026-07-22 14:40:07 +08:00
parent 49330744e5
commit c54f4214df
2 changed files with 91 additions and 3 deletions

View File

@@ -63,6 +63,15 @@ curl -fsS http://127.0.0.1:39180/health
仪表盘适合浏览和筛选;需要精确关联请求或比较版本时,打开 `Explore`,数据源选择 `Loki`
仪表盘包含两个日志面板:
- `HTTP Errors`:只显示能够解析出 HTTP `status >= 400` 的结构化日志。
- `Service Logs (health excluded)`:显示所选服务的普通日志,并默认排除例行 `/health` 请求。
API 不记录成功 `/health` 请求的开始和结束事件,以避免 Docker 日志与 Loki 被固定频率的探针日志占满。
如果 `/health` 返回非 2xx 或请求在中间件中失败,错误日志仍会保留。需要查看改造前的历史健康检查日志时,
`Explore` 中使用明确包含 `/health` 的查询,并把时间范围设置到对应部署时间之前。
## 常用 LogQL
查看教学反馈的全部日志:
@@ -71,6 +80,12 @@ curl -fsS http://127.0.0.1:39180/health
{application="teaching-feedback"}
```
排除改造前已采集的健康检查日志:
```logql
{application="teaching-feedback", service="api"} != "\"path\":\"/health\""
```
按服务、级别和文本筛选:
```logql