sncs1311/incident-response
GitHub: sncs1311/incident-response
基于本地 LLM 的自动化应急响应系统,通过可观测性技术栈实时检测应用故障,并逐步实现 AI 诊断、自动修复与告警通知的闭环。
Stars: 0 | Forks: 0
# 自动化应急响应系统
## 阶段 1 — 基础架构
启动本地可观测性技术栈以及一个 Python agent,用于从日志和指标中检测异常。
### 技术栈
| 组件 | 角色 |
|-----------|------|
| Loki + Promtail | 日志聚合 |
| Prometheus + cAdvisor + node-exporter | 指标 |
| Grafana | 仪表盘 |
| SQLite | 事件历史 |
| Python agent | 检测循环 |
### 启动所有服务
```
docker compose up --build -d
```
### 验证是否正常运行
```
# Loki 就绪?
curl http://localhost:3100/ready
# Prometheus targets 全部 UP?
open http://localhost:9090/targets
# Grafana (admin / admin)
open http://localhost:3000
# 观看 agent 检测 incidents
docker logs -f incident-agent
```
### 直接查询事件
```
sqlite3 data/incidents.db "SELECT id, service, severity, title, created_at FROM incidents ORDER BY created_at DESC LIMIT 10;"
```
### 生成测试错误(触发 agent)
```
# 频繁请求 API 以生成错误
for i in $(seq 1 50); do
curl -s -X POST http://localhost:8000/process -H "Content-Type: application/json" -d '{}' &
done
wait
```
### 项目结构
```
incident-response/
├── docker-compose.yml
├── monitoring/
│ ├── loki/
│ │ ├── loki-config.yml
│ │ └── promtail-config.yml
│ └── prometheus/
│ ├── prometheus.yml
│ └── alert_rules.yml
├── services/
│ ├── api-service/ # Flaky Flask API (generates errors)
│ └── worker-service/ # Background worker (fails every N jobs)
└── agent/
├── main.py # Detection loop
├── core/
│ ├── database.py # SQLite incident store
│ ├── loki_client.py # LogQL queries
│ └── prometheus_client.py # PromQL queries
└── Dockerfile
```
## 后续规划
- **阶段 2** — Ollama + Llama 3 诊断:原始日志 → 纯英文解释
- **阶段 3** — 自动修复:重启服务、清理磁盘、扩容容器
- **阶段 4** — Slack 告警 + 附带完整上下文的工单创建
标签:AIOps, AI风险缓解, API集成, Docker, 可观测性, 安全防御评估, 故障检测, 本地大模型, 模块化设计, 自动化修复, 自动化运维, 自定义请求头, 请求拦截, 逆向工具