314 lines
23 KiB
Markdown
314 lines
23 KiB
Markdown
<!-- WEHUB_ZH_README -->
|
||
> [!NOTE]
|
||
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
|
||
> [English](./README.en.md) · [原始项目](https://github.com/Tracer-Cloud/opensre) · [上游 README](https://github.com/Tracer-Cloud/opensre/blob/HEAD/README.md)
|
||
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
|
||
|
||
<div align="center">
|
||
|
||
<p align="center">
|
||
<img src="docs/logo/opensre-logo-white.svg" alt="OpenSRE" width="360" />
|
||
</p>
|
||
|
||
<h1>OpenSRE v0.1:构建你自己的 AI SRE 智能体</h1>
|
||
|
||
<p>面向 AI SRE 智能体的开源框架,以及它们持续改进所需的训练与评估环境。连接你已运行的 60+ 种工具,定义自己的工作流,并在自有基础设施上调查事故。</p>
|
||
|
||
<p align="center">
|
||
<a href="https://github.com/Tracer-Cloud/opensre/actions/workflows/ci.yml?branch=main"><img src="https://img.shields.io/github/actions/workflow/status/Tracer-Cloud/opensre/ci.yml?branch=main&style=for-the-badge" alt="CI status"></a>
|
||
<a href="https://github.com/Tracer-Cloud/opensre/releases"><img src="https://img.shields.io/badge/status-public%20alpha-orange?style=for-the-badge" alt="Project status: public alpha"></a>
|
||
<a href="https://github.com/Tracer-Cloud/opensre/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge" alt="Apache 2.0 License"></a>
|
||
<a href="https://discord.gg/7NTpevXf7w"><img src="https://img.shields.io/badge/Discord-Join%20Us-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord"></a>
|
||
<a href="https://greptile.com"><img src="https://img.shields.io/badge/Sponsored%20by-Greptile-27E99F?style=for-the-badge&labelColor=3D3B4F&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iMzY3IiBoZWlnaHQ9IjQyMCIgdmlld0JveD0iMCAwIDM2NyA0MjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI%2BCjxwYXRoIGQ9Ik0yNDAuMjY5IDQ5LjgxNTRMMTY2LjgwNCAxMTUuOTYzTDExNS45NjYgMTU5LjQ0TDE4MS4zMzUgMjIwLjU4NUwyNDkuNzg0IDE2Mi4wNDhMMTk2Ljc4IDExMi40N0wyNTMuMDY4IDYxLjc4ODFMMzYyLjYwNSAxNjQuMjQ2TDE3OC43MzkgMzIxLjQ4OUwzLjE0NTAyIDE1Ny4yNDJMMTg3LjAxMSAwTDI0MC4yNjkgNDkuODE1NFoiIGZpbGw9IiNGRkZGRkYiLz4KPHJlY3Qgd2lkdGg9IjIzNi40NTMiIGhlaWdodD0iODMuNDU2NiIgdHJhbnNmb3JtPSJtYXRyaXgoMC43NTQ3MSAtMC42NTYwNTkgMCAxIDE4OC4wMTcgMzM2LjU0NCkiIGZpbGw9IiNGRkZGRkYiLz4KPHJlY3Qgd2lkdGg9IjIzNi40NTMiIGhlaWdodD0iODMuNDU2NiIgdHJhbnNmb3JtPSJtYXRyaXgoMC43MzEzNTQgMC42ODE5OTggMCAxIDAgMTc0Ljk2MikiIGZpbGw9IiNGRkZGRkYiLz4KPC9zdmc%2BCg%3D%3D" alt="Sponsored by Greptile"></a>
|
||
</p>
|
||
|
||
<p align="center">
|
||
<a href="https://trendshift.io/repositories/25889" target="_blank">
|
||
<img
|
||
src="https://trendshift.io/api/badge/repositories/25889"
|
||
alt="Tracer-Cloud%2Fopensre | Trendshift"
|
||
style="height: 30px; width: auto;"
|
||
height="30"
|
||
/>
|
||
</a>
|
||
</p>
|
||
|
||
<p align="center">
|
||
<strong>
|
||
<a href="https://www.opensre.com/docs/quickstart">快速入门</a> ·
|
||
<a href="https://www.opensre.com/docs">文档</a> ·
|
||
<a href="https://opensre.com/docs/faq">常见问题</a> ·
|
||
<a href="https://trust.tracer.cloud/">安全</a>
|
||
</strong>
|
||
</p>
|
||
|
||
</div>
|
||
|
||
---
|
||
|
||
> 🚧 公开 Alpha:核心工作流可用于早期探索,但尚未完全稳定。项目正在积极开发中,API 与集成可能会演进
|
||
|
||
---
|
||
|
||
## 目录
|
||
|
||
- [为什么选择 OpenSRE?](#why-opensre)
|
||
- [安装](#install)
|
||
- [快速入门](#quick-start)
|
||
- [部署](#deployment)
|
||
- [OpenSRE 工作原理](#how-opensre-works)
|
||
- [基准测试](#benchmark)
|
||
- [能力与集成](#capabilities--integrations)
|
||
- [贡献与开发](#contributing--development)
|
||
- [安全](#security)
|
||
- [遥测](#telemetry)
|
||
- [许可证](#license)
|
||
- [引用](#citations)
|
||
|
||
---
|
||
|
||
## 为什么选择 OpenSRE?
|
||
|
||
当生产环境出现问题时,证据分散在日志、指标、链路追踪、运行手册(runbook)和 Slack 讨论串中。OpenSRE 是一个用于解决生产事故的开源 AI SRE 智能体框架,专为在自有基础设施上运行而构建。
|
||
|
||
我们这样做,是因为 SWE-bench<sup>1</sup> 为编码智能体提供了可扩展的训练数据和清晰的反馈。生产事故响应仍缺少同等的基础设施。
|
||
|
||
分布式故障比本地代码任务更慢、更嘈杂、更难模拟和评估,这也是 AI SRE,以及更广泛的面向生产调试的 AI,仍未被解决的原因。
|
||
|
||
OpenSRE 正在构建_这一_缺失的层次:
|
||
|
||
> 面向智能体基础设施事故响应的开放强化学习环境,配备端到端测试和合成事故模拟,以复现真实的生产故障
|
||
|
||
我们通过以下方式实现:
|
||
|
||
- 构建易于部署、可定制的 AI SRE 智能体,用于生产事故调查与响应
|
||
- 运行带评分的合成 RCA(根因分析)套件,检验根因准确性、所需证据以及对抗性干扰项(红鲱鱼)[(tests/synthetic)](tests/synthetic/rds_postgres)
|
||
- 在涵盖 Kubernetes、EC2、CloudWatch、Lambda、ECS Fargate 和 Flink 等云支撑场景的真实端到端测试中运行 [(tests/e2e)](tests/e2e)
|
||
- 保持语义化的测试目录命名,使 e2e 与 synthetic、本地与云之间的边界一目了然 [(tests/README.md)](tests/README.md)
|
||
|
||
我们的使命是在此之上构建 AI SRE 智能体,将其扩展到数千种真实的基础设施故障场景,并将 OpenSRE 确立为 AI SRE 的基准与训练场。
|
||
|
||
<sup>1</sup> https://arxiv.org/abs/2310.06770
|
||
|
||
---
|
||
|
||
## 安装
|
||
|
||
根安装器 URL 会自动检测 Unix shell 与 PowerShell,并从 `main` 安装最新构建。OpenSRE 迭代很快,因此 `main` 是常规安装的最新稳定版本。
|
||
|
||
macOS / Linux:
|
||
|
||
```bash
|
||
curl -fsSL https://install.opensre.com | bash
|
||
```
|
||
|
||
macOS/Linux 安装器不需要 sudo。若 `PATH` 上尚无可写的 bin 目录,则会安装到 `~/.local/bin`,并打印用于更新 PATH 的 shell 命令。
|
||
|
||
等价的显式 main 渠道形式:
|
||
|
||
```bash
|
||
curl -fsSL https://install.opensre.com | bash -s -- --main
|
||
```
|
||
|
||
Homebrew:
|
||
|
||
```bash
|
||
brew tap tracer-cloud/tap
|
||
brew install tracer-cloud/tap/opensre
|
||
```
|
||
|
||
Windows(PowerShell):
|
||
|
||
```powershell
|
||
irm https://install.opensre.com | iex
|
||
```
|
||
|
||
<!--
|
||
```bash
|
||
pipx install opensre
|
||
``` -->
|
||
|
||
---
|
||
|
||
## Quick Start
|
||
|
||
Configure once, then pick how you want to run investigations:
|
||
|
||
```bash
|
||
opensre onboard
|
||
```
|
||
|
||
**交互式 shell** — 不带子命令时,`opensre` 会启动 REPL(需要 TTY)。用自然语言描述事故、流式输出调查过程,并使用斜杠命令进行会话控制(`/help`、`/status`、`/cost`、`/sessions`、`/resume`、`/compact`、`/new`、`/exit`)、集成(`/integrations list`、`/integrations verify`)、本地智能体集群监控(`/agents`)以及推理深度(**OpenAI** 与 **Codex** 使用 `/effort` — `low` 至 `max`)。Ctrl+C 可取消进行中的调查,且不会丢失会话状态。完整参考见 **[交互式 shell 命令](https://www.opensre.com/docs/interactive-shell-commands)****。
|
||
|
||
```bash
|
||
opensre
|
||
```
|
||
|
||
**一次性调查** — 针对告警文件运行智能体一次:
|
||
|
||
```bash
|
||
opensre investigate -i tests/e2e/kubernetes/fixtures/datadog_k8s_alert.json
|
||
```
|
||
|
||
**远程运行时调查** — 按名称调查已部署的服务(实时健康状态、日志与部署状态):
|
||
|
||
```bash
|
||
opensre investigate --service api-backend
|
||
```
|
||
|
||
**Hermes 日志监视** — 跟踪 Hermes `errors.log`,对事故进行分类,并可选择通过 Telegram 告警:
|
||
|
||
```bash
|
||
opensre hermes watch
|
||
```
|
||
|
||
其他实用命令:
|
||
|
||
```bash
|
||
opensre integrations setup
|
||
opensre agents scan
|
||
opensre update
|
||
opensre uninstall # remove opensre and all local data
|
||
```
|
||
|
||
---
|
||
|
||
## 部署
|
||
|
||
两条主要的 AWS EC2 路径,以及一个通用托管选项:
|
||
|
||
- **EC2(Docker/ECR):** `make build-image`,然后 `make deploy` — 在同一实例上运行 `opensre-web` 与 `opensre-gateway` 容器。
|
||
- **Gateway(AMI + systemd):** `make bake-gateway`,然后 `make deploy-gateway` — 仅 Telegram 网关,无需 Docker,内置于自定义 AMI。
|
||
- **托管(Railway / ECS / Vercel):** 使用仓库中的 `Dockerfile` 部署;设置 `LLM_PROVIDER` 及对应的 API 密钥(见 [`.env.example`](.env.example)),若需持久化还需设置 `DATABASE_URI` 与 `REDIS_URI`。
|
||
|
||
**[完整部署步骤与前置条件 → DEPLOYMENT.md](DEPLOYMENT.md)**
|
||
|
||
---
|
||
|
||
## OpenSRE 工作原理
|
||
|
||
<img
|
||
src="https://github.com/user-attachments/assets/936ab1f2-9bda-438d-9897-e8e9cd98e335"
|
||
width="1064"
|
||
height="568"
|
||
alt="opensre-how-it-works-github"
|
||
/>
|
||
|
||
当告警触发时,OpenSRE 会自动:
|
||
|
||
1. **获取**告警上下文及关联的日志、指标、追踪(trace)和近期部署信息
|
||
2. 在外部 LLM 调用前(可选)**掩码处理**敏感标识符
|
||
3. 在工具调用循环中,跨已连接系统进行**推理**以验证假设
|
||
4. **生成**结构化调查报告,包含可能的根本原因及关联证据
|
||
5. **建议**后续步骤,并可选择执行修复操作
|
||
6. 直接将摘要**发布**到 Slack、PagerDuty 或 Telegram —— 无需切换上下文
|
||
|
||
关于移除旧的 graph 与 chain 框架层之后的当前代码级 agent 架构,请参阅 [AGENTS.md](AGENTS.md)。
|
||
|
||
---
|
||
|
||
## Benchmark
|
||
|
||
使用 **`make benchmark`** 重新生成数据;通过 **`make benchmark-update-readme`** 从缓存结果刷新此表。详见 **[docs/DEVELOPMENT.md](docs/DEVELOPMENT.md#benchmark)**。
|
||
|
||
<!-- BENCHMARK-START -->
|
||
|
||
_暂无 benchmark 结果。_
|
||
|
||
<!-- BENCHMARK-END -->
|
||
|
||
---
|
||
|
||
## Capabilities & integrations
|
||
|
||
| | |
|
||
| ---------------------------------------- | -------------------------------------------------------------------------------- |
|
||
| 🔍 **Structured incident investigation** | 跨日志、指标、追踪、部署与配置进行关联的根因分析 |
|
||
| 📋 **Runbook-aware reasoning** | OpenSRE 读取你的 runbook 并自动应用 |
|
||
| 🔗 **Evidence-backed root cause** | 每项结论均链接至支撑数据 |
|
||
| 🛡️ **Reversible identifier masking** | 在外部 LLM 调用前脱敏 pod、集群与账户 ID;输出时可还原 |
|
||
| 📊 **Session cost & history** | 按会话追踪 token(`/cost`)及可恢复的 REPL 会话(`/sessions`) |
|
||
| 👥 **Local agent fleet** | 监控本机上的 Claude Code、Cursor、Codex 及其他编码 agent |
|
||
| 🌐 **Remote runtime RCA** | 按名称调查已部署服务,含实时健康探测与近期日志 |
|
||
| 📡 **Hermes log watch** | 跟踪 Hermes 错误日志、分类事件并发送 Telegram 告警 |
|
||
| 🤖 **Full LLM flexibility** | 自带模型 — Anthropic、OpenAI、Codex、Ollama、Gemini、OpenRouter、NVIDIA NIM、Bedrock |
|
||
|
||
OpenSRE 可连接 **60+** 种工具,涵盖 LLM、可观测性、云基础设施、数据平台、事件管理与 MCP。完整矩阵(含路线图链接)见 **[产品文档](https://www.opensre.com/docs)**;**,随着项目发展,仓库内也维护有一份详细目录。
|
||
|
||
---
|
||
|
||
## Integrations
|
||
|
||
OpenSRE 可连接现代云技术栈中的 60+ 种工具与服务,从 LLM 提供商与可观测性平台,到基础设施、数据库与事件管理。
|
||
|
||
| Category | Integrations | Roadmap |
|
||
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||
| **AI / LLM Providers** | Anthropic · OpenAI · OpenAI Codex · Ollama · Google Gemini · OpenRouter · NVIDIA NIM · Bedrock | |
|
||
| **Observability** | <img src="docs/assets/icons/grafana.webp" width="16"> Grafana (Loki · Mimir · Tempo · annotations) · <img src="docs/assets/icons/datadog.svg" width="16"> Datadog · Honeycomb · Coralogix · <img src="docs/assets/icons/cloudwatch.png" width="16"> CloudWatch · <img src="docs/assets/icons/sentry.png" width="16"> Sentry · Elasticsearch · Better Stack · Splunk · Victoria Logs · SignOz · OpenObserve · OpenSearch · Azure Monitor · Hermes | [New Relic](https://github.com/Tracer-Cloud/opensre/issues/139) |
|
||
| **Infrastructure** | <img src="docs/assets/icons/kubernetes.png" width="16"> Kubernetes · <img src="docs/assets/icons/aws.png" width="16"> AWS (S3 · Lambda · EKS · EC2 · CloudTrail · Bedrock) · <img src="docs/assets/icons/gcp.jpg" width="16"> GCP · <img src="docs/assets/icons/azure.png" width="16"> Azure · ArgoCD · Helm · Jenkins | |
|
||
| **Database** | MongoDB · ClickHouse · PostgreSQL · MySQL · MariaDB · MongoDB Atlas · Azure SQL · Snowflake · Redis · RDS · Supabase | |
|
||
| **Data Platform** | Apache Airflow · Apache Kafka · Apache Spark · Prefect · RabbitMQ · Dagster | |
|
||
| **Dev Tools** | <img src="docs/assets/icons/github.webp" width="16"> GitHub · GitHub MCP · Bitbucket · GitLab | |
|
||
| **Incident Management** | <img src="docs/assets/icons/pagerduty.png" width="16"> PagerDuty · Opsgenie · Jira · Alertmanager · incident.io | [Trello](https://github.com/Tracer-Cloud/opensre/issues/361) · [ServiceNow](https://github.com/Tracer-Cloud/opensre/issues/314) · [Linear](https://github.com/Tracer-Cloud/opensre/issues/124) |
|
||
| **Communication** | <img src="docs/assets/icons/slack.png" width="16"> Slack · Google Docs · Discord · Telegram · WhatsApp | [Notion](https://github.com/Tracer-Cloud/opensre/issues/286) · [Teams](https://github.com/Tracer-Cloud/opensre/issues/138) · [Confluence](https://github.com/Tracer-Cloud/opensre/issues/313) |
|
||
| **Agent Deployment** | <img src="docs/assets/icons/vercel.png" width="16"> Vercel · <img src="docs/assets/icons/aws.png" width="16"> EC2 · <img src="docs/assets/icons/aws.png" width="16"> ECS · Railway | |
|
||
| **Protocols** | <img src="docs/assets/icons/mcp.svg" width="16"> MCP · <img src="docs/assets/icons/acp.png" width="16"> ACP · <img src="docs/assets/icons/openclaw.jpg" width="16"> OpenClaw | |
|
||
|
||
OpenSRE 由社区共建。想找安全的首次贡献?浏览 [`good first issue`](https://github.com/Tracer-Cloud/opensre/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) 工单,或参阅 [Good First Issues 指南](docs/good-first-issues/README.md)。完整流程见 **[CONTRIBUTING.md](CONTRIBUTING.md)**。
|
||
|
||
**本地环境:** **[SETUP.md](SETUP.md)**(全平台、Windows、MCP/OpenClaw)。
|
||
|
||
**在本仓库中开发:** **[docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)**(从源码安装、CI 一致性检查、开发容器、基准测试、部署详情、遥测参考)。
|
||
|
||
<p>
|
||
<a href="https://discord.gg/7NTpevXf7w">
|
||
<img src="https://img.shields.io/badge/Join%20our%20Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="加入我们的 Discord" />
|
||
</a>
|
||
</p>
|
||
|
||
<p align="center">
|
||
<a href="https://www.star-history.com/?type=date&repos=Tracer-Cloud%2Fopensre">
|
||
<picture>
|
||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=Tracer-Cloud/opensre&type=date&theme=dark&legend=top-left&sealed_token=LHlhQArnQVcZZDuHHjU19dJHIIzQx9WzB2xacqhOnA8REEAfcVO94FgGmjAMsR8iiPA3ELR-RmF_t2rtnLLj6ieZt6S4PGbFZ5Ev1HgIrg8KJNkJDYQob_BcV8MtWc2wQnahPyKX6B9PgqvoQxI7E6B6SkW7gXQEq1xLLGDZ2JHvv5b3kr7SYnUpq98y" />
|
||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=Tracer-Cloud/opensre&type=date&legend=top-left&sealed_token=LHlhQArnQVcZZDuHHjU19dJHIIzQx9WzB2xacqhOnA8REEAfcVO94FgGmjAMsR8iiPA3ELR-RmF_t2rtnLLj6ieZt6S4PGbFZ5Ev1HgIrg8KJNkJDYQob_BcV8MtWc2wQnahPyKX6B9PgqvoQxI7E6B6SkW7gXQEq1xLLGDZ2JHvv5b3kr7SYnUpq98y" />
|
||
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=Tracer-Cloud/opensre&type=date&legend=top-left&sealed_token=LHlhQArnQVcZZDuHHjU19dJHIIzQx9WzB2xacqhOnA8REEAfcVO94FgGmjAMsR8iiPA3ELR-RmF_t2rtnLLj6ieZt6S4PGbFZ5Ev1HgIrg8KJNkJDYQob_BcV8MtWc2wQnahPyKX6B9PgqvoQxI7E6B6SkW7gXQEq1xLLGDZ2JHvv5b3kr7SYnUpq98y" />
|
||
</picture>
|
||
</a>
|
||
</p>
|
||
|
||
感谢以下优秀贡献者:
|
||
|
||
<!-- readme: contributors -start -->
|
||
<a href="https://github.com/Tracer-Cloud/opensre/graphs/contributors">
|
||
<img src="https://contrib.rocks/image?repo=Tracer-Cloud/opensre&max=200" alt="Contributors" />
|
||
</a>
|
||
<!-- readme: contributors -end -->
|
||
|
||
---
|
||
|
||
## 安全
|
||
|
||
OpenSRE 面向生产环境设计:结构化且可审计的 LLM 提示词、默认在本地处理会话记录,且不会静默批量导出原始日志。负责任披露详见 **[SECURITY.md](SECURITY.md)**。
|
||
|
||
---
|
||
|
||
## 遥测
|
||
|
||
PostHog(产品分析)和 Sentry(错误监控)为 **默认开启、可主动关闭(opt-out)**。快速禁用:
|
||
|
||
```bash
|
||
export OPENSRE_NO_TELEMETRY=1
|
||
```
|
||
|
||
**[完整矩阵、DSN 覆盖与本地事件日志 → docs/DEVELOPMENT.md](docs/DEVELOPMENT.md#telemetry-and-privacy)**
|
||
|
||
---
|
||
|
||
## 许可证
|
||
|
||
Apache 2.0 — 详见 [LICENSE](LICENSE)。
|
||
|
||
## 引用
|
||
|
||
<sup>1</sup> https://arxiv.org/abs/2310.06770
|