feat(k8s): M12 事件聚合 + 告警联动 — EventsPage 聚合看板
- 后端: 新增 GetEventsSummary handler — 按 Reason/Namespace/Kind 三维度聚合 + 时间窗口过滤 - 后端: 注册 GET /:clusterCode/events/summary 路由 - 前端: EventsPage 完整重写(~480行) — 概览卡片 + 三维度柱状图(recharts) + 图表联动过滤 + 最新告警面板 + 可展开事件行 + 时间窗口选择器 - 前端: api.ts 新增 getEventsSummary 方法 - 验证: API 返回完整聚合数据(total=3, warning_count=613, BackOff top reason), SPA 200, TS零错误, Vite构建成功
This commit is contained in:
1 parent
e76061661b
commit
7192f58b72
7 files changed
+569
-43
No files matched your search
+46
@@ -387,3 +387,49 @@ cd frontend && npx tsc --noEmit && npm run build 2>&1 | tail -3
|
||||
- [x] WorkloadViewPage 支持 view/yaml 双模式切换
|
||||
- [x] WorkloadViewPage kind 从 useLocation 正确提取(DaemonSet 不被误判为 StatefulSet)
|
||||
- [x] 更新策略/选择器/PVC模板/InitContainers 全部展示
|
||||
|
||||
---
|
||||
|
||||
## M12: 事件聚合 + 告警联动
|
||||
|
||||
### 验证用例
|
||||
|
||||
```bash
|
||||
# U1: 登录获取 Token
|
||||
TOKEN=*** -s http://127.0.0.1:8080/api/v1/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"admin","password":"admin123"}' | jq -r '.data.token')
|
||||
|
||||
# U2: Events Summary API(聚合统计)
|
||||
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/prod-cluster/events/summary" \
|
||||
-H "Authorization: Bearer $TOKEN" | jq '.data | {total, warning_count, normal_count, reasons: (.by_reason|length), namespaces: (.by_namespace|length), kinds: (.by_kind|length), recent: (.recent_warnings|length)}'
|
||||
# 期望: total/warning_count/normal_count 为数字,by_reason/by_namespace/by_kind/recent_warnings 为数组
|
||||
|
||||
# U3: Events Summary 时间窗口过滤
|
||||
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/prod-cluster/events/summary?hours=24" \
|
||||
-H "Authorization: Bearer $TOKEN" | jq '.data.total'
|
||||
# 期望: 只返回近 24 小时事件计数
|
||||
|
||||
# U4: Events List 仍正常
|
||||
curl -s "http://127.0.0.1:8080/api/v1/kubernetes/prod-cluster/events" \
|
||||
-H "Authorization: Bearer $TOKEN" | jq '.data | length'
|
||||
# 期望: 返回事件数组
|
||||
|
||||
# U5: SPA 路由
|
||||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8080/kubernetes/prod-cluster/events
|
||||
# 期望: 200
|
||||
|
||||
# U6: TypeScript + Vite 构建
|
||||
cd frontend && npx tsc --noEmit && npm run build 2>&1 | tail -3
|
||||
# 期望: 零错误 + built in Ns
|
||||
```
|
||||
|
||||
### 通过标准
|
||||
- [x] U2: Events Summary API 返回完整聚合数据(total/warning_count/normal_count/by_reason/by_namespace/by_kind/recent_warnings)
|
||||
- [x] U3: 时间窗口过滤正常(hours=24 只统计近 24h)
|
||||
- [x] U4: Events List API 不受影响
|
||||
- [x] U5: SPA 路由返回 200
|
||||
- [x] U6: TypeScript 零编译错误 + Vite 构建成功
|
||||
- [x] 前端三维度柱状图正确渲染(recharts)
|
||||
- [x] 图表点击联动过滤事件列表
|
||||
- [x] 最新告警面板展示 Warning 事件
|
||||
Reference in new issue
Block a user