rijwanansari/OpsPilotdotnet10

GitHub: rijwanansari/OpsPilotdotnet10

基于 .NET 10 和 Semantic Kernel 的多智能体事件响应系统,通过编排分诊、根因分析、修复建议等 AI 智能体链路实现运维事件的自动化分析与处置。

Stars: 0 | Forks: 0

# OpsPilot — 多智能体事件响应系统 [![.NET 10](https://img.shields.io/badge/.NET-10.0-purple)](https://dotnet.microsoft.com/) [![Semantic Kernel](https://img.shields.io/badge/Semantic%20Kernel-1.74.0-blue)](https://github.com/microsoft/semantic-kernel) [![Clean Architecture](https://img.shields.io/badge/Architecture-Clean-green)]() ## 🚀 概述 OpsPilot 演示了企业级 AI 智能体如何超越聊天机器人,实现**真正的运维自动化**。当检测到支付 API 中断时,由专门的 AI 智能体组成的管道会自动执行以下操作: 1. **🔍 分诊智能体** — 使用 Semantic Kernel 工具调用 (`LogAnalysisPlugin`) 分析 45 条真实的日志条目 2. **🧠 根本原因智能体** — 确定可能的故障原因(例如,数据库连接池耗尽) 3. **🔧 修复智能体** — 提出按优先级排序的修复步骤,并提供精确的 SQL/kubectl 命令 4. **📋 GitHub 服务** — 模拟创建包含完整事件详情的 GitHub 议题 ## 📁 解决方案结构 ``` OpsPilot.slnx ├── src/ │ ├── OpsPilot.Domain/ # Domain entities (Incident, LogEntry, AgentResult, RemediationStep) │ ├── OpsPilot.Application/ # Interfaces, IncidentOrchestrator, SampleLogProvider │ ├── OpsPilot.Infrastructure/ # Semantic Kernel agents, LogAnalysisPlugin, GitHub simulator, DI │ └── OpsPilot.Console/ # Entry point — colorful CLI demo with ANSI output └── tests/ └── OpsPilot.Tests/ # xUnit tests (32 tests covering domain, application, infrastructure) ``` ## ⚡ 快速开始 ### 前置条件 - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) ### 运行(模拟模式 — 无需 API 密钥) ``` git clone https://github.com/rijwanansari/OpsPilotdotnet10.git cd OpsPilotdotnet10 dotnet run --project src/OpsPilot.Console ``` ### 运行测试 ``` dotnet test OpsPilot.slnx ``` ### 构建 ``` dotnet build OpsPilot.slnx ``` ## 🤖 演示的智能体概念 | 概念 | 实现 | |---|---| | **工具调用** | `LogAnalysisPlugin` 包含 3 个由分诊智能体调用的 `[KernelFunction]` 方法 | | **多智能体编排** | `IncidentOrchestrator` 将 Triage → RootCause → Fix → GitHub 串联起来 | | **推理工作流** | 每个智能体接收前一个智能体的结果以进行上下文推理 | | **自主行动** | 在管道结束时自动创建 GitHub 议题 | ## 🔧 生产环境配置 (Azure AI Foundry) 编辑 `src/OpsPilot.Console/appsettings.json`: ``` { "AzureAI": { "Endpoint": "https://your-foundry.openai.azure.com/", "ApiKey": "your-api-key", "DeploymentName": "gpt-4o", "UseSimulation": false }, "GitHub": { "Token": "your-github-pat", "Owner": "yourorg", "Repo": "payment-api", "SimulateOnly": false } } ``` 将 `UseSimulation: false` 设置为使用真实的 Azure AI Foundry + Semantic Kernel 进行实时推理。 ## 📊 示例事件场景 **事件**:支付 API 服务中断 — P0 严重级别 **收入影响**:约 $47K/分钟 **日志语料库**:5.2 分钟内跨 4 个服务的 45 条记录 **发现的根本原因**:由于未优化的 `SELECT *` 查询(缺少来自 #247 迁移的索引)与同时发生的 Redis 认证 token 轮换共同导致的数据库连接池耗尽。 **修复步骤**(总计 100 分钟): 1. 🔴 终止长时间运行的数据库查询 (`pg_terminate_backend`) 2. 🔴 重置熔断器 + 滚动重启 Pod 3. 🟠 通过 Kubernetes 密钥恢复 Redis 认证 token 4. 🟠 重建缺失的数据库索引 (`CREATE INDEX CONCURRENTLY`) 5. 🟡 修复存活探针 + 增加连接池大小 ## 🏗 架构 ``` User Trigger │ ▼ IncidentOrchestrator (Application layer) │ ├──► TriageAgent ──────► LogAnalysisPlugin (KernelFunctions: tool calling) │ │ │ └── AgentResult (triage analysis) │ ├──► RootCauseAgent ───► AgentResult (root cause + confidence) │ ├──► FixAgent ──────────► List (prioritized) │ └──► GitHubIssueService ► Issue URL (simulated or real) ``` ## 🧪 测试 分为 3 个类别的 32 个测试: - **领域测试**:实体创建、状态转换、属性验证 - **应用测试**:`SampleLogProvider` 语料库验证、带有存根的 `IncidentOrchestrator` 管道 - **基础设施测试**:`LogAnalysisPlugin` KernelFunction 逻辑(错误计数、速率计算、时间线)
标签:Agentic AI, AIOps, Azure AI, BurpSuite集成, CLI, DLL 劫持, GitHub集成, IT运维, Kubectl, .NET 10, PyRIT, Semantic Kernel, slnx解决方案, Socks5代理, WiFi技术, xUnit, 人工智能, 企业级应用, 单元测试, 多智能体系统, 大语言模型, 故障排查, 数据库连接池, 整洁架构, 智能运维, 根因分析, 模块化设计, 用户模式Hook绕过, 自动化修复, 自动化运维