clydecode8/AI-Incident-Response-Agent

GitHub: clydecode8/AI-Incident-Response-Agent

基于 ReAct 的 Agentic AI 生产事件自主调查与报告生成系统,能动态调用多源检索工具并自动评估调查质量,帮助 SRE 团队加速事件根因定位。

Stars: 0 | Forks: 0

# AI 事件响应 Agent 这是一个**基于 Agentic AI 的事件响应系统**,它能够通过选择合适的工具、从多个来源收集证据,并生成包含自动化质量评估且有理有据的事件报告,从而自主调查生产事件。 与遵循固定检索 pipeline 的传统 RAG 系统不同,本项目采用了一种 **Agentic AI** 方法,让 LLM 根据当前的调查上下文动态决定使用哪些工具。 ## 功能 - 🤖 使用 ReAct 的 Agentic AI 调查工作流 - 🔍 多来源证据检索 - 应用日志 - Linux 日志 - Hadoop 日志 - 代码库搜索 - 内部知识库 (RAG) - 📊 自动生成事件报告 - 🧠 混合 AI 评估框架 - 基于规则的评估 - DeepEval LLM-as-a-Judge - 📈 调查轨迹可视化 - 📋 带有自动监控的告警队列 - ✍️ 手动事件调查 - 🔄 支持多种 LLM (Gemini & Llama/Groq) # 系统架构 ``` ┌──────────────────┐ │ Production Alert │ └─────────┬────────┘ │ ▼ ┌──────────────────────┐ │ AI ReAct Agent │ └─────────┬────────────┘ │ ┌───────────────────┼────────────────────┐ │ │ │ ▼ ▼ ▼ Search Logs Search Codebase Retrieve Knowledge │ │ │ └───────────────────┼────────────────────┘ ▼ Evidence Collection │ ▼ Incident Report Generator │ ▼ Hybrid Evaluation Framework (Rule-based + DeepEval LLM-as-a-Judge) ``` # Agent 工作流 ``` Production Alert │ ▼ Reason about incident │ ▼ Select investigation tools │ ▼ Retrieve evidence │ ▼ Determine if more evidence is needed │ Yes │ No ▼ Continue Investigation │ ▼ Generate Incident Report │ ▼ Evaluate Investigation Quality ``` # 支持的调查工具 | 工具 | 用途 | |------|---------| | search_logs | 搜索应用、Linux 和 Hadoop 日志 | | search_metrics | 获取系统指标 | | search_codebase | 搜索源代码以查找相关实现 | | retrieve_knowledge | 使用 RAG 检索内部操作手册 | ## Agent 评估 ![评估](https://static.pigsec.cn/wp-content/uploads/repos/cas/f3/f3960f6ad753588c186757034dbf5d86f765e0c86558f6b86c56138c764669f8.png) ![评估](https://static.pigsec.cn/wp-content/uploads/repos/cas/60/6097685149b801e3fe28226669ea9a8e0d9e4b510772d372756ef91b2b22fa56.png) # 混合评估框架 系统不仅评估最终答案,还会同时评估以下内容: ## 1. 基于规则的评估 验证 agent 是否: - 选择了合适的调查工具 - 遵循了预期的调查工作流 - 收集了足够的证据 - 在适用时检索了知识 - 使用证据支持结论 ## 2. DeepEval (LLM-as-a-Judge) 评估内容: - 根本原因准确性 - 证据完整性 - 依据与忠实度 - 可操作的修复建议 - 事件隔离度 - 事件整体质量 # 技术栈 ## AI - Gemini - Llama (Groq) - ReAct Agent - 检索增强生成 (RAG) - DeepEval ## 后端 - Python - Streamlit ## 搜索 - Elasticsearch - Pinecone ## 监控 - 日志监控 - 指标监控 # 仓库结构 ``` agent/ react_agent.py incident_monitor.py evaluator.py tools.py knowledge/ logs/ metrics/ alerts/ evaluation/ runtime/ incident-demo/ ``` # 运行项目 ## 克隆仓库 ``` git clone https://github.com//ai-incident-response-agent.git cd ai-incident-response-agent ``` ## 安装依赖 ``` pip install -r requirements.txt ``` ## 配置环境 创建一个 `.env` ``` GROQ_API_KEY=... GROQ_MODEL=llama-3.1-8b-instant GEMINI_API_KEY=... GEMINI_MODEL=gemini-2.5-flash PINECONE_API_KEY =... PINECONE_INDEX_NAME =... PINECONE_HOST =... ``` ## 启动 Streamlit ``` streamlit run app.py ``` ## 启动监控 ``` python monitor_worker.py ``` ## 评估 每次完成调查后,都会使用混合评估框架进行自动评估。 示例指标: - 根本原因准确性 - 证据完整性 - 工具选择 - 依据 - 忠实度 - 修复质量 # 调查示例 ``` Alert PaymentService KafkaTimeoutException: Broker unavailable ↓ AI Agent ↓ Search Logs ↓ Search Codebase ↓ Retrieve Knowledge ↓ Generate Report ↓ Hybrid Evaluation ↓ PASS (95.4%) ``` # 未来改进 - 多 agent 协作 - 自动修复建议 - 实时 Grafana 集成 - Kubernetes 监控 - OpenTelemetry 链路追踪 - Human-in-the-loop 审批 - 额外的 LLM 提供商 - 混合搜索 + 重排序 # 动机 开发本项目是为了探索 **Agentic AI** 如何通过结合自主推理、检索增强生成(RAG)和工具编排来自动化事件调查。其目标是在生成适用于站点可靠性工程(SRE)工作流、有理有据、可解释且具有可操作性的事件报告的同时,减少人工调查时间。
标签:AIOps, Kubernetes, 运维自动化, 逆向工具