🚀 Self-Healing AIOps Multi-Agent System
Spring Boot • Multi-Agent Architecture • MCP Tool-Calling • Autonomous Healing
该项目是一个完整的多代理AIOps系统,它持续监控微服务,使用AI驱动的代理分析日志和指标,检测异常,并触发由Supervisor agent编排的自动修复操作。
它作为一种生产风格的概念验证(PoC),展示了现代企业如何实施人工智能驱动的自我修复基础设施。
🧠 系统架构(高级)
✔ Fully decoupled microservices ✔ All agents use MCP @Tool functions ✔ Supervisor orchestrates everything ✔ Healing actions performed automatically ⭐ Features
🟢 1.度量分析代理
分析实时系统指标:
CPU 使用率
内存使用
延迟
错误计数
AI生成的度量健康摘要
🟡 2.日志分析代理
执行智能日志分类:
检测:
数据库故障
死锁
OOM错误
GC开销
SQL查询速度慢
缓存/Redis问题
断路器转换
JWT故障
网络延迟问题
重复身份验证失败
提取物:
错误
警告
根本原因
🔴 3.异常检测代理
关联指标+日志以检测:
内存泄漏
数据库连接池耗尽
网络不稳定
CPU/内存峰值
延迟异常
安全问题
🔧 4.治疗剂
执行自主治疗:
正在重新启动微服务
重置数据库连接
清除缓存
扩大行动
🧠 5.监理代理
通过MCP工具调用调用所有代理
收集并合并所有输出
执行异常评估
触发自我修复
生成最终AIOps事件报告
📡 6.监控服务
通过提供以下内容来模拟真实的微服务:
随机指标
真实日志
健康状况
🧩 Project Structure
self-healing-aiops-system/
│
├── supervisor-service/
├── metrics-agent/
├── logs-agent/
├── anomaly-agent/
├── healing-agent/
└── monitored-service/每个文件夹都包含自己的Spring Boot微服务。
⚙️ 多代理工作流如何运行
主管→ 度量代理
主管→ 日志代理
主管将数据关联并发送给Anomaly Agent
如果检测到异常→ 治愈剂被触发
主管返回最终组合JSON报告
📝 Example Final Output
{
"metrics": {
"cpu": 41,
"memory": 76,
"latency": 134
},
"logs": {
"errors": [
"TimeoutException: DB connection failed",
"OutOfMemoryError: Java heap space"
],
"warnings": [
"High latency: 540ms",
"Memory usage high: 82%"
],
"rootCause": "Memory leak / heap exhaustion"
},
"anomaly": {
"anomaly": true,
"reason": "Critical errors found in logs."
},
"healingAction": {
"action": "restart",
"status": "SUCCESS",
"message": "Service restarted successfully."
},
"finalStatus": "System healed successfully"
}🛠️ Technologies Used
Layer Tech
Language Java 21
Framework Spring Boot 3.x
AI Spring AI (ChatClient + MCP Tool-Calling)
Protocol MCP – Model Context Protocol
Build System Maven
Communication REST APIs🚀 如何运行所有代理 1.️⃣ 启动监控服务 cd监控服务 mvn春季开机:运行
2.️⃣ 启动度量代理 cd度量代理 mvn春季开机:运行
3.️⃣ 启动日志代理 cd日志代理 mvn春季开机:运行
4.️⃣ 启动异常代理 cd异常剂 mvn春季开机:运行
5.️⃣ 启动治疗剂 cd治疗剂 mvn春季开机:运行
6.️⃣ 启动监督员服务 cd监督服务 mvn春季开机:运行
🔍 测试系统
访问:
👉 http://localhost:8086/supervise
______________________________________________________________________
🐳 使用Docker运行整个系统
该项目支持 一键式多代理启动 使用Docker Compose——无需手动运行服务。
先决条件
- 已安装Docker桌面
- Docker Compose已启用
- 在环境变量中配置的API键(
.env文件或系统环境变量)
______________________________________________________________________
🚀 一次启动所有代理
docker-compose up --build
Stop the system
bash
Copy code
docker-compose down
Once services start, open in browser:
📌 http://localhost:8086/supervise
This triggers the full AIOps workflow:
Metrics → Logs → Anomaly Detection → Healing → Final Report ✔
Container Overview
Service Container Port Purpose
monitored-service 8081 → 8080 Simulated target application
metrics-agent 5173 → 8080 Fetch metrics from monitored service
logs-agent 5174 → 8080 Analyze logs & classify issues
anomaly-agent 5175 → 8080 Detect abnormal behavior
healing-agent 5176 → 8080 Perform recovery actions
supervisor-service 8086 → 8080 Main orchestrator calling all agents
All containers communicate internally over a shared Docker network aiops-net.
🌍 Environment Variables
Create a .env file before running (without committing it to GitHub):
env
API_KEY=your_groq_or_openai_api_key_here
🔥 Advantages of Docker Mode
✔ Zero manual startup — one command boot
✔ Each service runs in its own isolated container
✔ Reproducible environment for demos & deployment
✔ Ready for Kubernetes migration later
---
If you want, I can also generate:
📌 **Docker badges** for README
📌 **Docker deploy script**
📌 **Kubernetes YAML next step**
Just say **"next: kube deployment"** or **"add docker badge🧪 Testing Scenarios Supported
✔ 内存泄漏 ✔ 数据库连接超时 ✔ 死锁 ✔ SQL查询速度慢 ✔ 高延迟 ✔ 认证失败 ✔ 断路器打开状态 ✔ Redis超时 ✔ 网络延迟问题
💡 所有代理协作检测问题、诊断根本原因并自主修复系统。
