基于 Multi-Agent 协作的云原生智能运维诊断平台
AIOps-Guardian 是一个基于大语言模型和传统 AIOps 算法的智能运维诊断平台。 系统通过 6 个专业 Agent 协作,结合 Isolation Forest 异常检测、Drain3 日志模板解析、 Pearson 关联分析等算法,实现 K8s 集群故障的自动化诊断和根因分析。
核心目标:将 MTTD(平均故障发现时间)从分钟级降低到秒级。
┌─────────────────────────────────────────────────────┐
│ 前端 Dashboard │
│ Vue3 + Element Plus │
├─────────────────────────────────────────────────────┤
│ API 网关 (FastAPI) │
├─────────────────────────────────────────────────────┤
│ Multi-Agent 诊断引擎 │
│ 规划Agent → 指标Agent + 日志Agent + 拓扑Agent │
│ → 决策Agent → 报告Agent │
├──────────────────────┬──────────────────────────────┤
│ AIOps 算法层 │ LLM + RAG 层 │
│ Isolation Forest │ DeepSeek API │
│ Drain3 日志解析 │ ChromaDB 知识库 │
│ Pearson 关联分析 │ Prompt 模板管理 │
├──────────────────────┴──────────────────────────────┤
│ 数据采集层 │
│ K8s API │ Prometheus │ Elasticsearch │
├─────────────────────────────────────────────────────┤
│ Kubernetes 集群(被观测对象) │
└─────────────────────────────────────────────────────┘
- 🤖 Multi-Agent 诊断引擎:6 个专业 Agent 基于 ReAct 模式协作,自动完成故障定位
- 📊 传统 AIOps 算法:Isolation Forest 异常检测 + Drain3 日志解析 + Pearson 关联分析
- 🧠 LLM 深度推理:集成 DeepSeek API,通过 Prompt Engineering 实现精准根因定位
- 📚 RAG 知识库:基于 ChromaDB 的历史故障案例检索,相似故障快速匹配
- 🔄 实时诊断:WebSocket 实时推送诊断进度和 Agent 思考过程
- 📈 可视化 Dashboard:Vue3 + ECharts 构建集群监控和诊断报告展示
- Python 3.11+
- Node.js 18+
- Docker & Docker Compose
- Kubernetes 集群(可使用 Kind/Minikube)
- DeepSeek API Key
git clone https://github.com/almostgali/aiops-guardian.git
cd aiops-guardiancp .env.example .env
# 编辑 .env,填入你的 DeepSeek API Keypip install -r requirements.txt --target="./.venv"
export PYTHONPATH="./.venv:$PYTHONPATH"docker compose up -d
# 启动 Elasticsearch + Prometheuspython scripts/seed_knowledge.pyuvicorn backend.main:app --reload --port 8000访问 http://localhost:8000/docs 查看 API 文档。
cd frontend
npm install
npm run dev访问 http://localhost:3000。
| 层次 | 技术 |
|---|---|
| 后端框架 | FastAPI + WebSocket |
| Agent 框架 | 自研 Agent 循环 + LangGraph 编排 |
| LLM | DeepSeek API(兼容 OpenAI 格式) |
| 异常检测 | scikit-learn (Isolation Forest) |
| 日志解析 | Drain3 |
| 向量数据库 | ChromaDB(RAG 知识库) |
| 搜索引擎 | Elasticsearch |
| 指标采集 | Prometheus + PromQL |
| K8s 交互 | kubernetes-client/python |
| 前端 | Vue3 + Element Plus |
aiops-guardian/
├── backend/
│ ├── main.py # FastAPI 入口
│ ├── config.py # 配置管理
│ ├── models.py # Pydantic 数据模型
│ ├── routers/ # API 路由
│ │ ├── diagnosis.py # 诊断 API
│ │ └── ws.py # WebSocket
│ ├── services/ # 业务逻辑
│ │ ├── collector.py # K8s 数据采集
│ │ ├── prom_collector.py # Prometheus 采集
│ │ ├── es_service.py # ES 日志服务
│ │ ├── detector.py # IF 异常检测
│ │ ├── log_parser.py # Drain3 日志解析
│ │ ├── correlation.py # Pearson 关联分析
│ │ ├── algorithm_pipeline.py # 算法流水线
│ │ ├── llm_client.py # LLM 客户端
│ │ ├── prompts.py # Prompt 模板
│ │ ├── tools.py # Agent 工具定义
│ │ ├── tool_executor.py # 工具执行器
│ │ ├── agent_loop.py # Multi-Agent 诊断
│ │ ├── knowledge_base.py # RAG 知识库
│ │ └── ws_manager.py # WebSocket 管理器
│ └── core/
│ └── k8s_client.py # K8s 异步客户端
├── frontend/ # Vue3 前端
├── scripts/
│ └── seed_knowledge.py # 知识库初始化
├── docker-compose.yml
├── requirements.txt
└── README.md
MIT