# Sentry

EvoHub receives Sentry alerts through an **Internal** custom integration. Issue alerts and metric alerts both open EvoHub alerts. An issue's alert resolves when the issue is resolved, archived or ignored in Sentry, and a metric alert's resolves when Sentry reports it resolved.

## Set it up

:::steps
### Create the integration
In EvoHub, go to **On-Call → Integrations → + Add Integration**, choose **Sentry**, pick an **Escalation Policy** and click **Create Integration**. Copy the **Webhook URL**.
### Create an internal integration
In Sentry's organization **Settings**, open **Developer Settings** (custom integrations) and create a new **Internal** integration.
### Set the URL and webhooks
Set **Webhook URL** to your webhook URL, enable **Alert Rule Action**, and under **Webhooks** check **issue**.

```text
https://evohub.io/ingest/sentry?key=YOUR_INTEGRATION_KEY
```
### Use it in alert rules
In each issue alert or metric alert rule that should page, add the action that sends a notification through your integration.
:::

The legacy Sentry **Webhooks** plugin is not supported; use an internal integration.

> [!NOTE]
> With **issue** checked, Sentry also sends every newly created issue to the integration, and each one opens an EvoHub alert whether or not an alert rule matched it. That webhook is also how issue alerts resolve.

## Turn on auto-resolve

- **Issue alerts** resolve through the **issue** webhook: when the issue is **resolved**, **archived** or **ignored** in Sentry, EvoHub resolves its alert. Keep **issue** checked.
- **Metric alerts** resolve on their own: the alert rule's **resolved** notification resolves the alert.

## What EvoHub reads

### Issue alerts and issue webhooks

| EvoHub alert | Taken from |
| --- | --- |
| Title | The issue's (or event's) `title`, or "Sentry Issue". |
| Description | The `culprit`. |
| Labels | `level`; for an issue alert, `rule` (`triggered_rule`) and the event's `environment` and `release` when set; for an issue webhook, `project` and `short_id`. |
| Link | The event's or the issue's `web_url`. It opens from the alert. |
| Fingerprint | The issue ID: `data.issue.id`, or `data.event.issue_id` for an issue alert, so the alert rule's notification and the issue webhook meet on the same alert. |

### Metric alerts

| EvoHub alert | Taken from |
| --- | --- |
| Title | `description_title`, else the alert rule name, else the incident title. |
| Description | `description_text`. |
| Labels | `alert_type` (`metric_alert`), `action` (`critical` or `warning`) and `url` (`web_url`). |
| Fingerprint | The metric alert incident's ID, so each incident is one alert. |

### Severity

| Sentry | EvoHub severity |
| --- | --- |
| Issue level `fatal` | critical |
| Issue level `error` | high |
| Issue level `warning` | medium |
| Issue level `info` | info |
| Issue level `debug` | low |
| Issue level missing or other | medium |
| Metric alert `critical` | critical |
| Metric alert `warning` | high |

## Resolve and deduplication

- An issue webhook with the action **resolved**, **archived** or **ignored** resolves the open alert for that issue. **assigned** changes nothing. **created** and **unresolved** open an alert.
- A metric alert's **resolved** notification resolves that incident's alert. A **warning** followed by **critical** for the same incident stays one alert, recorded as **Retriggered**.
- Repeated notifications for an issue whose alert is still open are recorded as **Retriggered**.
- A delivery with no issue, event or metric alert in it (an installation webhook, for example) is answered with success and opens nothing.

## Troubleshooting

- **`401 INVALID_KEY`**: the URL's key is wrong or the integration is disabled. Copy the **Webhook URL** again from the integration.
- **Issue alerts never resolve**: **issue** is not checked under **Webhooks** in the internal integration.
- **An alert for every new issue**: that is the **issue** webhook. Remove the check if you only want alert rules to page — issue alerts then no longer resolve automatically.
- **Nothing arrives from an alert rule**: the rule has no action for your integration, or the integration's **Alert Rule Action** is off.

## Related

- [Integrations overview](https://docs.evohub.io/integrations-overview.md)
- [Datadog](https://docs.evohub.io/datadog.md)
- [Escalation policies](https://docs.evohub.io/escalation-policies.md)
