# Grafana & Better Stack integration

This integration allows you to create Uptime incidents from Grafana automatically.

## Connecting Grafana and Uptime

1. Go to [Integrations](https://uptime.betterstack.com/team/0/integrations/ ";_blank").
2. Click the **Importing data** tab.
3. Scroll down and look for the **Infrastructure monitoring** section.
4. Find the Grafana card and click **Add**.
5. In the new window, name your Grafana integration (e.g., `Backend service`) and click **Save changes**. Keep this page open; you will need the webhook URL in a moment.

### In Grafana

1. Open the Grafana instance you want to integrate with Better Stack.
2. Open **Alerting** → **Contact points** from the left-hand sidebar.
3. Click **Create contact point** and fill in the **Name** of your choice.
4. Select the **Webhook** integration.
5. In the URL field, input the **Webhook URL** found in the Uptime Grafana integration settings.
6. In the Webhook settings, select **POST** as the HTTP Method.
7. Click **Save contact point** to save contact point settings.

### Assign the contact point to an alert rule

1. In Grafana, open **Alerting** → **Alert rules** and edit the rule you want to send to Better Stack.
2. In the alert rule settings, scroll down to the **Notifications** section.
3. Select the contact point you created in the previous step.
4. Click **Save rule and exit** to apply the changes.

That is it! 🎉 Now, when Grafana triggers an alert, it will be sent into Uptime.

## How the integration works

Grafana sends alert notifications to the Better Stack webhook URL as HTTP POST requests. Better Stack supports both:

- **Grafana native alerts** — legacy format with `state`, `dashboardId`, `panelId`, and `ruleId` fields.
- **Grafana Alertmanager format** — used in Grafana 8+ Unified Alerting, which sends Prometheus-compatible payloads with an `alerts` array.

When Grafana sends an `alerting` or `no_data` state, Better Stack creates a new incident. When the state changes to `ok`, the corresponding incident is automatically resolved.
