关于 oncall-irm
用于配置和验证 Grafana OnCall 与 IRM 的告警路由、升级链和排班,适合在 Grafana Cloud 中管理事件响应的团队,并提供集成配置与端到端检查流程。
主要功能
- 01配置告警集成与路由
- 02设计并测试升级链
- 03从 iCal 创建排班
- 04告警通知与解决指南
适用场景
- 01将 Alertmanager 告警接入 IRM
- 02上线前测试路由规则
- 03构建并验证升级链
- 04从 iCal 创建值班排班
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ grafana/ skills --skill oncall-irm安装后在 Claude Code 中输入/oncall-irm确认已加载。
附带文件references/integrations.mdreferences/templates-schedules.md
详细介绍
Grafana OnCall 与 IRM
OnCall 文档:https://grafana.com/docs/oncall/latest/ IRM 文档:https://grafana.com/docs/grafana-cloud/alerting-and-irm/
Grafana OnCall OSS 处于维护模式(于 2026 年 3 月归档)。云用户请使用 IRM。概念(链、排班、集成)完全相同。
前提条件
- 启用了 IRM/OnCall 的 Grafana Cloud 堆栈
- API 令牌(
Authorization: <token>) - Slack 工作区,以及用于安装 OnCall 应用的管理员(用于 ChatOps)
核心概念
| 概念 | 描述 |
|---|---|
| 集成 | 接收告警的 Webhook URL;每个来源一个 |
| 路由 | 将告警映射到升级链的 Jinja2 条件(首个为 True 的条件生效) |
| 升级链 | 等待 / 通知排班 / 通知团队 / Webhook / 自动解决步骤 |
| 排班 | 基于日历的轮班(Web / iCal / Terraform) |
| 告警组 | 通过分组 ID 模板合并的相关告警 |
| 通知策略 | 每位用户的通知渠道 — Slack、移动推送、短信、电话、电子邮件 |
流程:告警 → 集成 → 路由模板 → 升级链 → 通知 → 确认 / 解决。
常见工作流
1. 接入 Alertmanager → IRM 并验证路由
# 1. In IRM: New integration → Alertmanager. Copy the webhook URL.
# 2. alertmanager.yml (see references/integrations.md for full block):
receivers:
- name: grafana-oncall
webhook_configs:
- url: https://<stack>.grafana.net/integrations/v1/alertmanager/<id>/
send_resolved: true
max_alerts: 100
# 3. Test the routing template BEFORE going live (UI: Integration → Route → "Preview")
# Paste a sample payload (use a real Alertmanager test webhook). Expect:
# Routing result: True
# Escalation chain selected: <expected chain>
# If False — your Jinja expression is wrong; fix and re-preview.
# 4. End-to-end test — fire amtool (or any test webhook) at the URL
amtool alert add foo severity=critical team=platform --alertmanager.url http://localhost:9093
# 5. Verify in IRM → Alert Groups (should appear within ~5s) — confirm:
# - Correct route fired
# - Correct schedule/user notified
# - Slack message appeared in the configured channel
路由模板语法和 Jinja 辅助函数:references/templates-schedules.md。
其他集成(Grafana Alerting、通用 Webhook、Slack):references/integrations.md。
2. 创建升级链并验证
1. Notify "Primary On-Call" (Important Notifications)
2. Wait 5 min
3. Notify "Primary On-Call" (Default Notifications)
4. Wait 10 min
5. Notify team "Platform"
6. Trigger outgoing webhook (PagerDuty / ticket)
# Verify: create a test alert (UI → Integration → "Send demo alert"),
# then watch the alert-group timeline tick through steps 1 → 6.
# Use IRM → Escalation Chains → "Test" if available, otherwise the demo alert is the canonical check.
3. 根据 iCal 创建排班并验证“当前谁在值班”
# 1. Create the schedule
curl -X POST https://<stack>.grafana.net/api/v1/schedules/ \
-H "Authorization: <token>" -H "Content-Type: application/json" \
-d '{"name":"Platform On-Call",
"ical_url_primary":"https://calendar.example.com/platform.ics",
"slack":{"channel_id":"C123456ABC","user_group_id":"S123456ABC"}}'
# 2. Verify the schedule was created
curl -s https://<stack>.grafana.net/api/v1/schedules/ \
-H "Authorization: <token>" | jq '.results[] | select(.name=="Platform On-Call")'
# 3. Verify who is on-call right now
curl -s https://<stack>.grafana.net/api/v1/schedules/<schedule_id>/next_shifts/ \
-H "Authorization: <token>" | jq '.results[0]'
# Expect a shift starting now (or recently) with the right user_id.
Terraform 方案和轮班块:references/templates-schedules.md。
最佳实践
- 将升级链保持在 ≤4 个级别,并设置明确的最终步骤(Webhook 到 PagerDuty 或自动解决)
- 始终在 Alertmanager 中设置
send_resolved: true,以便 OnCall 自动解决 - 在 Alertmanager Webhook 配置中使用
max_alerts: 100 - 结合使用 Slack 和移动推送以提高送达可靠性
- 将集成和排班分配给团队,以支持 RBAC
资源
评论
支持 Markdown