dark5un/sre-watchtower
GitHub: dark5un/sre-watchtower
一个由本地 agent 驱动的 CI 与生产环境事件响应系统,通过 GitHub Issue 自动完成故障的监控、调查和报告。
Stars: 0 | Forks: 0
# SRE Watchtower
一个由 agent 驱动的、用于 CI pipeline 和生产环境告警的事件响应系统。
## 方法论
Watchtower 运行一个四阶段的循环:**监控、确认、调查、报告**。
当 pipeline 失败时,responder 工作流会创建一个带有失败上下文的 GitHub Issue。本地 agent(运行在你的机器上)会轮询处于开启状态的 issue,分析日志,并撰写一份结构化的调查报告。该 issue 是唯一的真实数据源。
## 架构
```
Pipeline fails
→ Responder workflow creates a GitHub Issue (sre-watchtower label)
→ Local agent polls for open issues
→ Agent acknowledges, investigates, reports
→ Issue is the record of the incident
```
responder 工作流运行在 GitHub Actions 上。它不调用任何 LLM,也不需要任何 API key。它只负责创建 issue。
agent 运行在你的本地机器上。LLM 的 API key 仅存在于你的本地环境中,永远不会出现在代码仓库中。
## 快速开始
```
# 安装
uv sync
# 设置
export GITHUB_TOKEN="ghp_..."
export WATCHTOWER_CONFIG=".sre/manifest.yaml"
# 运行一次
uv run python -m watchtower.cli
# 或者作为一个 cron job (每 5 分钟)
echo "*/5 * * * * cd /path/to/sre-watchtower && uv run python -m watchtower.cli" | crontab -
```
## 配置
编辑 `.sre/manifest.yaml`:
```
version: 1
repos:
- owner: dark5un
name: local-cloud
branch: main
ci_watcher:
enabled: true
interval: "*/5 * * * *"
acknowledge: session
max_actions:
- report # agent can only report, not act
```
## 测试
```
uv run pytest tests/ -v
```
## 本地测试
```
./scripts/test-local.sh
```
这将创建一个模拟的 issue,以 dry-run 模式运行 agent,并验证输出结果。
## 项目结构
```
src/watchtower/
models.py # Data models: Issue, Manifest, WorkflowRun
github_client.py # GitHub API client
investigator.py # Log analysis (LLM + fallback)
agent.py # Orchestration loop
cli.py # CLI entry point
tests/ # Unit tests with mocks
.github/workflows/
responder.yml # Creates issue on pipeline failure
flaky-test.yml # Deliberately flaky workflow for testing
ci.yml # Runs the test suite
```
标签:AI智能体, BurpSuite集成, C2, SRE, 偏差过滤, 自动化运维, 逆向工具