# Connect Grafana Alerting to SREbox On-call

> Route Grafana Alerting webhooks into SREbox for rota coverage, paging and incidents while retaining Grafana dashboards and telemetry.

Use this integration when Grafana should continue to evaluate and visualise your metrics while SREbox handles on-call response. You do not need to send Grafana metrics or logs to SREbox. The incoming webhook integration requires an on-call eligible plan and is assigned to one SREbox escalation policy.

## 1. Prepare SREbox

1. Create an on-call rota with current responders and notification methods.
2. Create and enable an escalation policy with at least one rota tier. Check provider setup and SMS/voice allowances before production use.
3. Open **On-call → Integrations → Add integration**, name it **Grafana production**, and select the policy.
4. Copy the endpoint and one-time webhook key. Store the key in your secrets manager. SREbox stores only its digest; rotate it in SREbox if it is exposed or lost.

## 2. Add a Grafana webhook contact point

In Grafana Alerting, add a **Webhook** contact point. Set the URL to the SREbox integration endpoint. Add an HTTP header named `Authorization` with value `Bearer YOUR_SREBOX_WEBHOOK_KEY`. Keep the token in Grafana's protected configuration and do not put it in the URL or message template.

Use Grafana's standard webhook payload. SREbox reads the `alerts` array, each alert's `fingerprint`, `status`, `labels` and `annotations`, along with the common envelope status. It maps `labels.alertname` to the title, `labels.severity` or `labels.priority` to severity, `labels.instance` or `labels.host` to source, and annotation `summary`/`description` to responder context. Labels and annotations are retained as bounded alert context in the incident message. If a label is absent, use a custom payload with the generic fields described below.

Grafana's built-in webhook HMAC signature option is not currently verified by SREbox. Leave that option disabled and use the SREbox bearer key. SREbox applies the endpoint's anonymous request throttle and a 64 KB request body limit.

## 3. Route by labels

Create Grafana notification policies that match labels such as `team`, `environment` or `severity`. For each destination team, create a separate Grafana contact point and SREbox integration assigned to that team's escalation policy. SREbox does not currently inspect labels to choose among multiple policies within one integration. Route only the alert groups you intend to page; do not enable an unfiltered catch-all until you have reviewed its scope.

## 4. Firing, deduplication and recovery

Grafana may send multiple alerts in one webhook request. SREbox uses each alert's stable `fingerprint` as its external ID. Repeated firing deliveries for an active fingerprint update the incident rather than opening another incident or sending another first-tier page. A `resolved` alert with the same fingerprint resolves the matching active incident and cancels pending pages. A later new firing after recovery opens a new incident.

Confirm Grafana sends resolved notifications. Test one controlled firing and recovery from **Alerting → Alert rules**, then check **On-call → Incidents** and the integration's last-received time. The SREbox endpoint does not return Grafana's full contact-point delivery history; use Grafana notification delivery status and SREbox incident history together when troubleshooting.

## Generic custom payload

Use a custom JSON body only when you need to map a Grafana rule to a specific identifier or message. Send one alert per object or an `alerts` array; each item needs an `external_id` (or `fingerprint`), `title`, and `status` (`firing` or `resolved`). Optional fields are `severity`, `source` and `message`.

```json
{
  "alerts": [
    {
      "external_id": "stable-alert-fingerprint",
      "title": "Checkout latency high",
      "status": "firing",
      "severity": "high",
      "source": "checkout-api",
      "message": "p95 latency exceeded the team threshold"
    }
  ]
}
```

The endpoint accepts `POST` JSON, up to 100 alerts and 64 KB total. Alert IDs are unique within an integration. Batches containing duplicate IDs are rejected so the sender can correct its grouping.

## Troubleshooting and safety

- **404:** endpoint/key is wrong, key was rotated, or integration is paused. This response intentionally does not distinguish those cases.
- **400:** check JSON structure, non-empty stable ID/title, firing/resolved status, and severity spelling.
- **403:** on-call is not available on the workspace plan.
- **409:** the selected policy is disabled, handoff-only, or has no usable rota tier.
- **413:** reduce the body below 64 KB; large labels/annotations can exceed the limit.
- **No page:** check the incident policy, rota coverage, responder contact methods, provider configuration and plan credits.
- **Recovery leaves an incident open:** verify that Grafana sent `resolved` for the same fingerprint and that the integration still points to the intended policy.

Review labels and annotations before forwarding them; do not send credentials, tokens, customer secrets or personal data that responders do not need. TLS protects the request in transit. Rotate the bearer key after personnel changes or suspected exposure. SREbox currently offers a last-received timestamp, not a per-delivery webhook audit log.

Official references: [Grafana webhook contact point](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/manage-contact-points/integrations/webhook-notifier/), [Grafana notification policies](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/).
