Installation

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

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

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

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

Download and extract to your repository:

.github/skills/alerting-irm/

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

Skill Files (4)

SKILL.md 7.5 KB
---
name: alerting-irm
license: Apache-2.0
description: Configure Grafana Alerting, Incident Response Management (IRM), and SLOs end-to-end — provisions Grafana-managed and data-source-managed alert rules, contact points (Slack/PagerDuty/email/webhook), notification policies with hierarchical matchers, silences, mute timings, on-call schedules and escalation chains, incident-management integrations, and SLOs with multi-window burn-rate alerts. Use when configuring alerts, debugging notification routing, setting up on-call rotations, declaring or managing incidents, defining SLOs, provisioning alerting via YAML or API, picking matchers for a notification policy, building a PagerDuty/Slack webhook receiver, or troubleshooting why an alert isn't firing — even when the user says "page me on errors", "alert me when X happens", "route this to the platform team", or "set up an SLO" without naming Alerting or IRM.
---

# Grafana Alerting & IRM

> **Docs**: https://grafana.com/docs/grafana/latest/alerting.md

## Common Workflows

### Provisioning a new alert end-to-end

1. **Create contact points** (where notifications go):
   ```bash
   curl -X POST https://grafana.example.com/api/v1/provisioning/contact-points \
     -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' \
     -d @contact-points.json
   ```
   Verify:
   ```bash
   curl https://grafana.example.com/api/v1/provisioning/contact-points \
     -H 'Authorization: Bearer <token>' | jq '.[].name'
   ```

2. **Add notification policies** (which alerts go where) — see [§ Notification policies](#notification-policies) below for the matchers pattern.

3. **Write the alert rule** — pick the type:
   - Grafana-managed → see [references/alerting.md § Grafana-managed alert rule](references/alerting.md#grafana-managed-alert-rule-yaml-provisioning)
   - Prometheus/Mimir ruler → see [references/alerting.md § Prometheus / Mimir alert rule](references/alerting.md#prometheus--mimir-alert-rule-ruler)
   - Loki LogQL → see [references/alerting.md § Loki alert rule](references/alerting.md#loki-alert-rule-logql)

4. **Verify routing** before going live:
   ```bash
   # Force-fire a test alert from the rule's UI, then check Alertmanager's view
   curl https://grafana.example.com/api/alertmanager/grafana/api/v2/alerts \
     -H 'Authorization: Bearer <token>' | jq '.[] | {alertname: .labels.alertname, receiver: .receivers}'
   ```
   The expected receiver should appear. If the wrong receiver appears, re-check the policy's matchers.

### Routing alerts to IRM / on-call

1. In IRM, create an Integration of type "Grafana Alerting webhook" → copy the integration URL
2. Add a webhook contact point in Grafana Alerting pointing at that URL (full YAML in [references/irm.md § Routing](references/irm.md#routing-from-grafana-alerting-to-irm))
3. Add a notification policy matcher routing the right severity to the new contact point
4. Verify: trigger a test alert; it should appear in IRM within ~30s. Full debug procedure in [references/irm.md § Verifying the IRM integration](references/irm.md#verifying-the-irm-integration).

### Defining an SLO

1. Create the SLO via UI or API → Grafana auto-generates recording rules, dashboards, and burn-rate alerts (the generated YAML is in [references/slo.md](references/slo.md))
2. **Use multi-window burn-rate alerts**, not single-window — see [references/slo.md § Multi-window burn-rate alerts](references/slo.md#multi-window-burn-rate-alerts-recommended) for why single-window fires on noise
3. Verify with the 4-step pattern in [references/slo.md § Validating SLO config](references/slo.md#validating-slo-config)

## Contact Points (YAML provisioning)

```yaml
# provisioning/alerting/contact_points.yaml
apiVersion: 1
contactPoints:
  - orgId: 1
    name: pagerduty-critical
    receivers:
      - uid: pd-receiver
        type: pagerduty
        settings:
          integrationKey: YOUR_PAGERDUTY_KEY
          severity: critical

  - orgId: 1
    name: slack-alerts
    receivers:
      - uid: slack-receiver
        type: slack
        settings:
          url: https://hooks.slack.com/services/YOUR/WEBHOOK/URL
          channel: '#alerts'
```

For email, webhook, Teams, Telegram, OnCall, and other receiver types, see [references/alerting.md § Contact point receiver types](references/alerting.md#contact-point-receiver-types).

## Notification policies

Hierarchical routing tree with label matchers:

```yaml
# provisioning/alerting/notification_policies.yaml
apiVersion: 1
policies:
  - orgId: 1
    receiver: default-receiver
    group_by: ['alertname', 'cluster', 'service']
    group_wait: 30s
    group_interval: 5m
    repeat_interval: 12h
    routes:
      # Critical alerts → PagerDuty
      - receiver: pagerduty-critical
        matchers:
          - severity = critical
        group_wait: 10s
        repeat_interval: 4h

      # Platform team → Slack, but page on critical
      - receiver: slack-alerts
        matchers:
          - team = platform
        routes:
          - receiver: pagerduty-critical
            matchers:
              - severity = critical

      # Everything else → email
      - receiver: email-alerts
        matchers:
          - severity =~ "warning|info"
```

## Silences

Suppress notifications for matching alerts without stopping evaluation:

```bash
curl -X POST https://grafana.example.com/api/alertmanager/grafana/api/v2/silences \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "matchers": [
      {"name": "alertname", "value": "HighErrorRate", "isRegex": false},
      {"name": "env", "value": "staging", "isRegex": false}
    ],
    "startsAt": "2024-01-01T00:00:00Z",
    "endsAt": "2024-01-01T02:00:00Z",
    "comment": "Maintenance window",
    "createdBy": "admin"
  }'

# Verify it was created
curl https://grafana.example.com/api/alertmanager/grafana/api/v2/silences \
  -H 'Authorization: Bearer <token>' | jq '.[] | select(.status.state == "active")'
```

## Alert rule states

| State | Description |
|-------|-------------|
| **Normal** | Condition not met |
| **Pending** | Condition met, waiting for `for` duration |
| **Firing** | Condition met for full `for` duration |
| **NoData** | Query returned no data |
| **Error** | Query/evaluation error |
| **Recovering** | Was firing, condition no longer met |

## Provisioning directory layout

```
provisioning/alerting/
├── alert_rules.yaml          # Alert and recording rules
├── contact_points.yaml       # Notification destinations
├── notification_policies.yaml  # Routing tree
├── templates.yaml            # Message templates
└── mute_timings.yaml         # Recurring mute windows
```

## API provisioning (keeps UI editable)

Add `X-Disable-Provenance: true` to keep resources editable in the UI after API provisioning:

```bash
curl -X PUT https://grafana.example.com/api/v1/provisioning/policies \
  -H 'Authorization: Bearer <token>' \
  -H 'X-Disable-Provenance: true' \
  -H 'Content-Type: application/json' \
  -d @policy.json

curl -X POST https://grafana.example.com/api/v1/provisioning/alert-rules \
  -H 'Authorization: Bearer <token>' \
  -H 'X-Disable-Provenance: true' \
  -H 'Content-Type: application/json' \
  -d @rule.json
```

## References

- [`references/alerting.md`](references/alerting.md) — full alert rule YAML (Grafana-managed / Prometheus / Loki) + notification templates
- [`references/slo.md`](references/slo.md) — generated SLO recording rules + multi-window burn-rate alert pattern + validation steps
- [`references/irm.md`](references/irm.md) — IRM capabilities, integration sources, Alerting → IRM routing + verification + common failure modes
references/
alerting.md 4.6 KB
# Alert rule examples

Full YAML for the three rule types Grafana supports. The main SKILL.md keeps concise inline examples; this file has the complete patterns plus advanced queries.

## Contents

- [Grafana-managed alert rule (YAML provisioning)](#grafana-managed-alert-rule-yaml-provisioning)
- [Prometheus / Mimir alert rule (ruler)](#prometheus--mimir-alert-rule-ruler)
- [Loki alert rule (LogQL)](#loki-alert-rule-logql)
- [Contact point receiver types](#contact-point-receiver-types)
- [Notification templates](#notification-templates)

## Grafana-managed alert rule (YAML provisioning)

```yaml
# provisioning/alerting/rules.yaml
apiVersion: 1
groups:
  - orgId: 1
    name: MyAlertGroup
    folder: MyFolder
    interval: 1m
    rules:
      - uid: high-error-rate
        title: High Error Rate
        condition: C
        data:
          - refId: A
            datasourceUid: prometheus
            relativeTimeRange:
              from: 300   # 5 minutes
              to: 0
            model:
              expr: sum(rate(http_requests_total{status=~"5.."}[5m])) by (service)
          - refId: B
            datasourceUid: __expr__
            model:
              type: reduce
              refId: B
              expression: A
              reducer: last
          - refId: C
            datasourceUid: __expr__
            model:
              type: math
              refId: C
              expression: $B > 0.05
        noDataState: NoData
        execErrState: Alerting
        for: 5m
        labels:
          severity: critical
          team: platform
        annotations:
          summary: "High error rate on {{ $labels.service }}"
          description: "Error rate is {{ $values.B }}%"
          runbook_url: "https://runbooks.example.com/high-error-rate"
```

## Prometheus / Mimir alert rule (ruler)

```yaml
groups:
  - name: service-alerts
    interval: 1m
    rules:
      - alert: HighErrorRate
        expr: |
          sum(rate(http_requests_total{status=~"5.."}[5m])) by (service)
          /
          sum(rate(http_requests_total[5m])) by (service)
          > 0.05
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "High error rate: {{ $labels.service }}"

      - alert: HighLatency
        expr: histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) > 1
        for: 2m
        labels:
          severity: warning
        annotations:
          summary: "P95 latency > 1s on {{ $labels.service }}"

      # Recording rule
      - record: job:http_requests:rate5m
        expr: sum(rate(http_requests_total[5m])) by (job)
```

## Loki alert rule (LogQL)

```yaml
groups:
  - name: log-alerts
    rules:
      - alert: HighErrorLogs
        expr: |
          sum(rate({app="myapp"} |= "error" [5m])) by (app)
          /
          sum(rate({app="myapp"}[5m])) by (app)
          > 0.05
        for: 10m
        labels:
          severity: page
        annotations:
          summary: "High error log rate for {{ $labels.app }}"

      - alert: CredentialsLeak
        expr: |
          sum by (cluster, job, pod) (
            count_over_time({namespace="prod"} |~ "https?://(\\w+):(\\w+)@" [5m]) > 0
          )
        for: 5m
        labels:
          severity: critical
```

## Contact point receiver types

SKILL.md shows PagerDuty + Slack inline. Other receiver types use the same shape under `receivers[].settings`:

```yaml
# Email
- orgId: 1
  name: email-alerts
  receivers:
    - uid: email-receiver
      type: email
      settings:
        addresses: 'oncall@example.com;alerts@example.com'

# Generic webhook
- orgId: 1
  name: webhook-alerts
  receivers:
    - uid: webhook-receiver
      type: webhook
      settings:
        url: https://your-endpoint.com/grafana-alerts
        httpMethod: POST
```

Other supported `type` values (full settings shape in [Grafana Alerting contact-point docs](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/manage-contact-points/integrations/)): `teams`, `telegram`, `discord`, `opsgenie`, `victorops`, `sns`, `googlechat`, `line`, `wecom`, `kafka`, `oncall` (Grafana OnCall webhook).

## Notification templates

```
# Custom Slack template
{{ define "slack.custom.title" }}
  [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}]
  {{ .CommonLabels.alertname }}
{{ end }}

{{ define "slack.custom.text" }}
{{ range .Alerts }}
*Alert:* {{ .Annotations.summary }}
*Severity:* {{ .Labels.severity }}
*Service:* {{ .Labels.service }}
*Details:* {{ .Annotations.description }}
{{ if .Annotations.runbook_url }}*Runbook:* {{ .Annotations.runbook_url }}{{ end }}
{{ end }}
{{ end }}
```
irm.md 2.2 KB
# IRM — on-call and incident management

## Capabilities

- **On-call schedules**: rotating shifts, overrides, escalation policies
- **Alert routing**: receive from Grafana Alerting, Prometheus, Datadog, PagerDuty, etc.
- **Incident management**: declare incidents, add participants, track tasks and timeline
- **Escalation chains**: auto-escalate if no response after N minutes
- **Integrations**: Slack, Teams, Telegram, GitHub, Jira, StatusPage

## Integration sources

| Source | Setup |
|--------|-------|
| Grafana Alerting | Native — configure in contact points (use IRM webhook receiver type) |
| Prometheus Alertmanager | Webhook URL from IRM |
| Datadog | Webhook integration |
| PagerDuty | Event integration |
| Jira | Issue-triggered alerts |
| Custom | Generic webhook |

## Routing from Grafana Alerting to IRM

In `provisioning/alerting/contact_points.yaml`:

```yaml
apiVersion: 1
contactPoints:
  - orgId: 1
    name: irm-routing
    receivers:
      - uid: irm-webhook
        type: webhook
        settings:
          url: https://<region>.grafana.net/api/plugins/grafana-irm-app/resources/integrations/<integration-id>/webhook
          httpMethod: POST
```

Then route alerts to this contact point via a notification policy matcher (e.g. `severity = page`).

## Verifying the IRM integration

1. Trigger a test alert in Grafana (use the "Test" button in the alert rule UI, or send a fake one via `POST /api/v1/alerts`)
2. In the IRM UI, the alert should appear under the matching integration within ~30 seconds
3. If it doesn't:
   - Check the webhook URL matches the integration's URL in IRM
   - Check the notification policy actually routes to the `irm-routing` contact point
   - Check Grafana logs for HTTP errors on the webhook POST

## Common failure modes

| Symptom | Likely cause |
|---|---|
| Alert fires in Grafana but never reaches IRM | Notification policy doesn't match the alert's labels; check matchers in `policies.yaml` |
| Alert reaches IRM but no on-call notification | Escalation chain misconfigured (e.g. no users in the rotation, or quiet hours suppressing) |
| Same alert opens duplicate IRM incidents | Group_by on the notification policy isn't including the unique-ifying labels |
slo.md 2.1 KB
# SLOs and burn-rate alerts

Grafana auto-generates recording rules, dashboards, and burn-rate alerts when you define an SLO via the UI or API. Reference YAML for the generated artifacts:

## Generated recording rules

```yaml
groups:
  - name: slo_availability
    interval: 1m
    rules:
      - record: slo:availability:ratio_rate5m
        expr: |
          sum(rate(http_requests_total{status!~"5.."}[5m])) by (service)
          / sum(rate(http_requests_total[5m])) by (service)

      - record: slo:error_budget:remaining
        expr: |
          (slo:availability:ratio_rate30d - 0.999) / (1 - 0.999)
```

## Burn-rate alerts

```yaml
- alert: SLOBurnRateHigh
  expr: |
    slo:burn_rate:ratio_rate1h > 14.4      # 1h window, 5% budget in 1h
  for: 2m
  labels:
    severity: critical
  annotations:
    summary: "SLO burn rate critical for {{ $labels.service }}"
```

## Multi-window burn-rate alerts (recommended)

The single 1h-window check above fires on transient noise. Better to require burn rate above threshold in BOTH a long window (1h, the "sustained" signal) AND a short window (5m, the "still burning right now" signal):

```yaml
- alert: SLOBurnRateFast
  expr: |
    slo:burn_rate:ratio_rate1h > 14.4
    and
    slo:burn_rate:ratio_rate5m > 14.4
  for: 2m
  labels:
    severity: critical
```

The `and` filters out: (a) a single 5m spike that wasn't actually a sustained issue (1h window stays low), and (b) a slow burn that already recovered (5m window now low). This is the Google SRE "multi-window, multi-burn-rate" pattern — see [SRE Workbook ch. 5](https://sre.google/workbook/alerting-on-slos/).

## Validating SLO config

After creating an SLO:
1. Check recording rules are running: `GET /api/v1/rules?type=record` should include the SLO's recording rules
2. Wait for the rules to evaluate at least once (default interval 1m)
3. Verify burn rate is computed: `GET /api/v1/query?query=slo:burn_rate:ratio_rate1h` should return a numeric value (not empty)
4. Test the alert: force a failure (e.g. inject errors in staging) and confirm the alert fires within the `for` duration

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