introspection-recipes/incident-response
GitHub: introspection-recipes/incident-response
基于 Pi Agent 框架的事件响应编排方案,串联 Datadog、PagerDuty、Sentry 和 GitHub 自动完成告警调查、错误分流、修复 PR 起草和事后报告编写。
Stars: 0 | Forks: 0
# 事件响应
事件编排器:调查 Datadog 和 PagerDuty 告警,通过 CLI/API 后备机制对 Sentry 问题进行分流,起草修复 PR,并在解决后编写事后分析报告。
## 试一试
```
recipes install github:introspection-recipes/incident-response
pi --recipe incident-response
```
对于本地开发:
```
recipes doctor .
recipes install .
pi --recipe incident-response
```
## 包含内容
- `agent`:事件指挥官。
- `alert-investigator`:指标、日志、告警和部署关联。
- `sentry-triage`:问题复现和修复计划工作节点。
- `postmortem-writer`:时间线、影响、原因和后续跟进编写器。
- `incident-response`、`hotfix-playbook` 和 `sentry-cli` 技能。
## MCP 配置
该方案为 PagerDuty、Datadog、GitHub 和 Slack 使用已验证的 MCP 服务器。
如果 `.pi/mcp.local.json` 尚不存在,`recipes install` 会将其写入已安装的方案中。
在启动 Pi 之前,请填写安装时打印出的环境变量:
```
export PAGERDUTY_MCP_URL=https://mcp.pagerduty.com/mcp
export PAGERDUTY_API_KEY=...
export DATADOG_MCP_URL=https://mcp.datadoghq.com/api/unstable/mcp-server/mcp
export DD_API_KEY=...
export DD_APPLICATION_KEY=...
export GITHUB_MCP_URL=https://api.githubcopilot.com/mcp/
export GITHUB_MCP_AUTH_TOKEN=...
export SLACK_MCP_URL=https://mcp.slack.com/mcp
export SLACK_MCP_TOKEN=...
pi --recipe incident-response
```
PagerDuty 使用其官方托管的 MCP 端点,并在 `Authorization: Token token=...` 标头中携带 PagerDuty API 密钥。Datadog 使用其官方托管的 MCP 端点,并携带 `DD-API-KEY` 和 `DD-APPLICATION-KEY` 标头。GitHub 使用官方的远程 GitHub MCP 端点,并在 `Authorization: Bearer ...` 中携带 GitHub PAT。Slack 使用 Slack 托管的 MCP token。
该方案仅允许已验证的工具名称:
- PagerDuty:`list_incidents`、`manage_incidents`
- Datadog:`search_datadog_logs`、`search_datadog_metrics`
- GitHub:`create_pull_request`
- Slack:`slack_send_message_draft`
在此启动方案中未启用 Sentry MCP,因为 Sentry 的托管 MCP 路径使用 OAuth 流程,并且之前的 `sentry_get_issue` 名称并不是真正的 Sentry MCP 工具。
## Sentry CLI/API 后备机制
Sentry 在 MCP 之外通过官方 Sentry CLI 或 REST API 提供支持。
在启动 Pi 之前设置这些内容:
```
export SENTRY_AUTH_TOKEN=...
export SENTRY_ORG=...
export SENTRY_PROJECT=...
export SENTRY_URL=https://sentry.io
```
`sentry-cli` 技能会告知分流 agent 在已安装 `sentry` CLI 时优先使用它,否则使用 Sentry REST API 并携带 `Authorization: Bearer $SENTRY_AUTH_TOKEN`。除非您明确要求 agent 更改问题状态,否则该后备机制是只读的。
标签:AIOps, LLM代理, MCP, 自动化运维