Installation

Install as Agent Plugin Recommended
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install oncall-irm@skills-hub

Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled). Plugin oncall-irm v1.0.0 follows the Agent Plugins spec.

Install with the gh extension
gh skills-hub install oncall-irm

Don't have the extension? Run gh extension install samueltauil/skills-hub first.

Download and extract to your repository:

.github/skills/oncall-irm/

Extract the ZIP to .github/skills/ in your repo. The folder name must match oncall-irm for Copilot to auto-discover it.

Skill Files (3)

SKILL.md 5.4 KB
---
name: oncall-irm
license: Apache-2.0
description: Route alerts, run on-call rotations, and drive incidents in Grafana IRM / OnCall — integrations (Alertmanager / Grafana Alerting / generic webhook / PagerDuty), Jinja2 routing + grouping templates, escalation chains (wait → notify schedule → notify team → webhook → auto-resolve), schedules (web + iCal + Terraform `grafana_oncall_schedule`), Slack chatops with Acknowledge/Resolve/Silence, and the P1-P4 incident lifecycle. Use when wiring Alertmanager to OnCall, deciding which team gets paged, building rotations from a Google Calendar / iCal, hooking up Slack notifications, or declaring an incident from an alert — even when the user says "page the platform team on critical alerts", "send Prometheus alerts to Slack", "set up our on-call rota", "escalation policy", or "auto-resolve when the alert clears" without naming OnCall / IRM. Heads up — OnCall OSS is in maintenance mode (archived March 2026); Grafana Cloud users should use IRM.
---

# Grafana OnCall & IRM

> **OnCall docs**: https://grafana.com/docs/oncall/latest/
> **IRM docs**: https://grafana.com/docs/grafana-cloud/alerting-and-irm/

> Grafana OnCall OSS is in maintenance mode (archived March 2026). Cloud users → **IRM**. Concepts (chains, schedules, integrations) are identical.

## Prerequisites

- Grafana Cloud stack with IRM/OnCall enabled
- API token (`Authorization: <token>`)
- Slack workspace + admin to install the OnCall app (for ChatOps)

## Core concepts

| Concept | Description |
|---------|-------------|
| **Integration** | Webhook URL accepting alerts; one per source |
| **Route** | Jinja2 condition that maps to an escalation chain (first True wins) |
| **Escalation Chain** | Wait / notify schedule / notify team / webhook / auto-resolve steps |
| **Schedule** | Calendar-based rotation (web / iCal / Terraform) |
| **Alert Group** | Related alerts collapsed by a Grouping ID template |
| **Notification Policy** | Per-user channels — Slack, mobile push, SMS, phone, email |

Flow: alert → integration → routing template → escalation chain → notifications → ack / resolve.

## Common Workflows

### 1. Wire Alertmanager → IRM and verify routing

```yaml
# 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
```

```bash
# 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
```

Routing template syntax + Jinja helpers: [`references/templates-schedules.md`](references/templates-schedules.md).
Other integrations (Grafana Alerting, generic webhook, Slack): [`references/integrations.md`](references/integrations.md).

### 2. Build an escalation chain + verify

```
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)
```

```bash
# 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. Create a schedule from iCal + verify "who is on-call right now"

```bash
# 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 variant + shift block: [`references/templates-schedules.md`](references/templates-schedules.md).

## Best practices

- Keep chains ≤4 levels with a definitive final step (webhook to PagerDuty or auto-resolve)
- Always set `send_resolved: true` in Alertmanager so OnCall auto-resolves
- Use `max_alerts: 100` in Alertmanager webhook config
- Combine Slack + mobile push for delivery reliability
- Assign integrations/schedules to teams for RBAC

## Resources

- [OnCall API](https://grafana.com/docs/oncall/latest/oncall-api-reference/)
- [IRM docs](https://grafana.com/docs/grafana-cloud/alerting-and-irm/)
- [Routing template helpers](https://grafana.com/docs/oncall/latest/configure/jinja2-template-functions/)
references/
integrations.md 2.1 KB
# Integrations

## Alertmanager / Prometheus

```yaml
# alertmanager.yml
receivers:
  - name: grafana-oncall
    webhook_configs:
      - url: https://<your-stack>.grafana.net/integrations/v1/alertmanager/<id>/
        send_resolved: true
        max_alerts: 100        # prevent oversized payloads

route:
  receiver:        grafana-oncall
  group_by:        [alertname, cluster]
  group_wait:      30s
  group_interval:  5m
  repeat_interval: 4h
```

## Grafana Alerting (same instance)

1. OnCall / IRM → Integrations → New Integration → **Grafana Alerting**
2. Click **Quick Connect** — auto-creates a contact point
3. Link the contact point to a notification policy in Grafana Alerting

## Webhook (custom / generic)

```bash
# Send
curl -X POST https://<stack>.grafana.net/integrations/v1/formatted_webhook/<id>/ \
  -H "Content-Type: application/json" \
  -d '{
    "alert_uid": "incident-123",
    "title": "Database CPU High",
    "state": "alerting",
    "message": "db-prod-01 CPU at 95% for 10 minutes",
    "link_to_upstream_details": "https://grafana.example.com/d/abc123"
  }'

# Resolve
curl -X POST https://<stack>.grafana.net/integrations/v1/formatted_webhook/<id>/ \
  -H "Content-Type: application/json" \
  -d '{"alert_uid": "incident-123", "state": "ok"}'
```

Recognized fields: `alert_uid`, `title`, `state` (`alerting`/`ok`), `message`, `image_url`, `link_to_upstream_details`.

## Slack

1. **Install**: OnCall Settings → Chat Ops → Slack → *Install Slack Integration*
2. **Connect users**: each user → Profile → Connect to Slack
3. **Set default channel** for alert routing
4. **Add to escalation**: "Notify by Slack mentions" step

Slack message actions: Acknowledge, Resolve, Silence, Add responders, Add note.
Slash commands: `/escalate`, `/oncall`.

## RBAC roles

| Role | Access |
|------|--------|
| `oncall-admin` | Full access |
| `oncall-editor` | Create/edit integrations, schedules, escalation chains |
| `oncall-viewer` | Read-only |
| `oncall-notifications-receiver` | Receive alerts only |

## Rate limits

- 300 alerts / integration / 5 min
- 500 alerts / org / 5 min
- 300 API requests / key / 5 min
templates-schedules.md 3.2 KB
# Routing templates, schedules, escalation chains, API

## Jinja2 routing templates

Return `True` / `False`. First matching route wins.

```jinja2
{# Critical → PagerDuty escalation #}
{{ payload.labels.severity == "critical" }}

{# Team-based #}
{{ payload.labels.team == "platform" }}

{# Substring on a label #}
{{ "database" in payload.labels.get("component", "") }}

{# Default catch-all #}
{{ true }}
```

Grouping ID (consolidates related alerts):

```jinja2
{{ payload.labels.alertname }}-{{ payload.labels.instance }}
```

Advanced template helpers:

```jinja2
{{ payload.field | b64decode }}
{{ "pattern" | regex_match(payload.message) }}
{{ datetimeformat_as_timezone(payload.startsAt, "UTC") }}
{{ payload.values | tojson_pretty }}
```

## Escalation chain step types

- **Wait** — pause N minutes
- **Notify users from schedule** — current on-call
- **Notify team** — all team members
- **Notify users** — specific named users
- **Trigger outgoing webhook**
- **Auto-resolve** after N minutes
- **Round-robin** through a list

Example chain:

```
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 webhook (PagerDuty / ticketing)
```

## On-call schedule — iCal import

```bash
curl -X POST https://<stack>.grafana.net/api/v1/schedules/ \
  -H "Authorization: <api-key>" -H "Content-Type: application/json" \
  -d '{
    "name": "Platform On-Call",
    "ical_url_primary":   "https://calendar.example.com/platform-oncall.ics",
    "ical_url_overrides": "https://calendar.example.com/overrides.ics",
    "slack": { "channel_id": "C123456ABC", "user_group_id": "S123456ABC" }
  }'
```

## Terraform schedule + shift

```hcl
resource "grafana_oncall_schedule" "platform" {
  name = "Platform On-Call"
  type = "calendar"
  shifts = [
    grafana_oncall_on_call_shift.weekday.id,
    grafana_oncall_on_call_shift.weekend.id,
  ]
}

resource "grafana_oncall_on_call_shift" "weekday" {
  name           = "Weekday"
  type           = "rolling_users"
  start          = "2024-01-01T09:00:00"
  duration       = 3600 * 8
  frequency      = "weekly"
  users_per_slot = 1
  rolling_users  = [["user-id-1"], ["user-id-2"], ["user-id-3"]]
}
```

## API quick reference

Base URL: `https://<stack>.grafana.net/api/v1/`

```bash
TOKEN=<api-key>; BASE=https://<stack>.grafana.net/api/v1
curl "$BASE/integrations/"                    -H "Authorization: $TOKEN"
curl -X POST "$BASE/escalation_chains/"       -H "Authorization: $TOKEN" \
     -H "Content-Type: application/json" -d '{"name":"Platform Critical","team_id":"<id>"}'
curl "$BASE/schedules/"                       -H "Authorization: $TOKEN"
curl "$BASE/alert_groups/?page=1&perpage=25"  -H "Authorization: $TOKEN"
curl "$BASE/schedules/<schedule_id>/next_shifts/" -H "Authorization: $TOKEN"
```

## Incident lifecycle (IRM)

When an alert group escalates to incident:

1. **Declare** — alert group → "Declare Incident" or Slack `/incident declare`
2. **Severity** — P1-P4
3. **Add responders**
4. **Status flow** — Investigating → Identified → Monitoring → Resolved
5. **Timeline** auto-tracks all actions; add manual notes
6. **Postmortem** — auto-draft from timeline on resolution

License (Apache-2.0)

View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/grafana/skills/blob/main/LICENSE