feat: add traceable scoped AIOps diagnosis

This commit is contained in:
aruo
2026-07-04 22:57:28 +08:00
parent 246c99b954
commit 23ee05c7c3
32 changed files with 1179 additions and 25 deletions
+48
View File
@@ -78,6 +78,43 @@ Expected result:
- `success` is `true`.
- A later trace query shows `data.session.feedback` as `useful`.
## 4. Run AIOps Alert Diagnosis
```powershell
$aiopsSessionId = "mvp-demo-aiops-payment-cpu-001"
$aiopsBody = @{
sessionId = $aiopsSessionId
alertName = "HighCPUUsage"
service = "payment-service"
severity = "P1"
description = "服务 payment-service 的 CPU 使用率持续超过 80%,当前值为 92%。实例: pod-payment-service-7d8f9c6b5-x2k4m。"
timeRange = "last_15m"
userRequest = "请结合 Prometheus 活动告警、system-metrics 日志和知识库生成告警分析报告。"
} | ConvertTo-Json
Invoke-WebRequest `
-Method Post `
-Uri "http://localhost:9900/api/ai_ops" `
-ContentType "application/json" `
-Body $aiopsBody
```
Expected result:
- The SSE stream starts with a `session` message containing `mvp-demo-aiops-payment-cpu-001`.
- The stream later contains an AIOps alert analysis report focused on the supplied `HighCPUUsage/payment-service` payload.
- A trace query for the same session id returns `data.session.agentFlow` as `AI_OPS`.
- `data.session.answer` contains the final alert analysis report when a report is generated.
- `data.toolInvocations` contains evidence tools such as `lookup_knowledge`, `query_logs`, or `query_metrics` when the runtime uses them.
Query the AIOps trace:
```powershell
Invoke-RestMethod `
-Method Get `
-Uri "http://localhost:9900/api/diagnosis/$aiopsSessionId/trace"
```
## Demo Story
The important interview story is:
@@ -92,3 +129,14 @@ one session id
-> feedback
-> trace API for replay and audit
```
The AIOps story uses the same audit spine:
```text
one session id
-> alert payload
-> AIOps planner/executor execution
-> evidence tools
-> alert analysis report
-> trace API for replay and audit
```