Sentry
Record every release in Sentry, resolve the issues a release fixes, read error spikes after a release as a signal that holds a wave or opens an incident, map Sentry projects to deployments, and what happens when Sentry is down.
Connect Sentry and three things happen.
- Releases are recorded. When a Wardn release finishes in a mapped deployment, Wardn makes a release in Sentry for the mapped project, finalizes it and records the deploy, so Sentry can tell errors apart by release. The release is named
<deployment>@<sha7>: the deployment and the first seven characters of the snapshot. - Optionally, fixed issues are resolved. Wardn sends the release's commit, so Sentry can resolve the issues whose commit messages say they fix them.
- Error spikes are a signal. Wardn reads each mapped project's error counts. A spike after a release lands is shown as a signal, can hold the next wave through a check, and can open a Wardn incident.
Wardn reads Sentry's projects and error counts and writes releases and deploys. It writes nothing else.
Only what has been run against Sentry's documented API through test fakes is described here. No real Sentry was available when this was built, so the exact shapes of Sentry's events-stats, issues and release replies, of the webhook payloads, and the internal integration setup below are untested against the real service. A self-hosted Sentry is expected to answer the same way, and is untested as well.
Connect it
You need integration:manage (Owners and Admins) and a server with WARDN_SECRET_MASTER_KEY set. Create an auth token in Sentry with org:read, project:read, project:releases and event:read, then:
curl -fsS -X PUT "$WARDN_API_URL/api/v1/sentry" \
-H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' \
-d '{"name":"Sentry","baseUrl":"https://sentry.io","organization":"acme","authToken":"…"}'baseUrl is https://sentry.io, which is what you get when you leave it out, or the https address of a self-hosted Sentry. It cannot name a private, loopback or link-local address. organization is the slug in Sentry's address. Wardn checks the address, the organization and the token with Sentry before keeping anything.
Credentials are write-only. The token goes into Wardn's sealed secret store under integrations/sentry/<connection>/auth-token. The API and the page never show it: they show where it is kept (Wardn · integrations/sentry/…/auth-token) and whether the secret store has it (Found or Not found). Connect again with a new authToken to change it; leave it out to keep the one that is there.
The first connection returns webhookPath and, once, a signingToken (whtok_…). Afterwards only its last four characters are shown (whtok_••••3b9e). POST /api/v1/sentry/signing-token makes a new one and shows it once; the old one stops working at once. In the web app the same is under Integrations, Connect Sentry.
POST /api/v1/sentry/test makes real calls to Sentry with the stored token and says how long they took, the organization and how many projects it shows. POST /api/v1/sentry/sync reads Sentry now.
Set up in Sentry
- In Sentry, create an internal integration.
- Set its webhook URL to
https://<your-wardn>/api/v1/webhooks/sentry/<id>(thewebhookPath), use the signing token as its client secret, and tick issue and metric alerts. - Send a test event.
Sentry then signs each delivery with the client secret and sends it in Sentry-Hook-Signature.
Webhooks
A delivery is a prompt, not a statement. Wardn reads the error counts of the project it names, or of every mapped project when it names none, from Sentry itself, and acts on what Sentry says. A forged, replayed or reordered delivery can cost a read and cannot change what Wardn believes. The organization is the one the connection belongs to, never one the body names.
A delivery is believed only when Sentry-Hook-Signature holds the hex HMAC-SHA256 of the raw body under the signing token, compared in constant time, and, when Sentry-Hook-Timestamp is present, the timestamp is within five minutes of now.
| Delivery | Answer |
|---|---|
| Wrong or missing signature, a stale or unreadable timestamp, an unknown connection, another organization's connection, a body over 1 MiB | The same 401 for all of them; Sentry is not asked |
| One seen in the last ten minutes | 200, ignored (replay) |
| Sentry is paused on the Integrations page | 200, ignored (paused) |
| Error spikes are off | 200, nothing read |
| Sentry cannot be read right now | 503, so Sentry sends it again; the retry is not taken for a replay |
The route is public (there is no session), rate limited like the other public routes, and can only make Wardn read Sentry.
Webhooks are not the only way Wardn learns. Every minute it reads the organization and the error counts of the mapped projects, so a spike is seen without a delivery too, and an old or failed read makes Sentry stale on its page: a stale Sentry sees no spikes.
Which project reports for which deployment
curl -fsS -X PUT "$WARDN_API_URL/api/v1/sentry/projects" \
-H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' \
-d '{"projects":[{"slug":"payments-api","deploymentId":"…","environments":["prod","staging"]}]}'This replaces the whole mapping. A project is mapped once and every deployment must exist. environments narrows both release tracking and spike watching to the named environments; empty means every one. GET /api/v1/sentry/available-projects lists the projects Sentry has (at most a thousand) and says which are mapped already. The page shows 6 mapped · 2 not mapped.
Release tracking
PUT /api/v1/sentry/settings replaces the settings. It takes the whole object, so the page sends what it has with one field changed.
| Setting | Meaning |
|---|---|
releaseTracking | Make a release in Sentry when a Wardn release finishes in a mapped deployment. On by default |
resolveFixed | Send the release's commit so Sentry can resolve the issues its commit messages say they fix. Needs the repository connected in Sentry. Off by default |
environments | Wardn environments releases are made for; empty means every mapped one |
A release is made only when the release completed, for each mapped project whose environments and the settings' environments both name the environment it landed in. Each one is made, finalized and given a deploy. A finish that has been told already is not told again. Releases never wait on Sentry: if Sentry cannot be reached the release goes on, and the recording is retried.
Error spikes
| Setting | Meaning |
|---|---|
spikeEnabled | Read error counts for spikes. On by default |
spikeMultiple | How many times the last day's usual error rate a spike is. 2 to 20, default 3 |
spikeMinutes | For how many minutes the rate must hold. 1 to 60, default 5 |
openIncident | Open an incident for each new issue in a release when a spike follows it in production. Off by default |
A spike is at least N times the 24 hour baseline for M minutes. Wardn needs at least six hours of history before it judges anything, ignores a window with fewer than ten errors so a quiet project does not flap, and wants the spike to be still going on: each half of the window must itself be at the multiple, so a burst that has already stopped is not a spike.
A spike that begins is recorded as a signal and read against the release that landed in the last hour:
- With no release in the last hour, it is only noted.
- In an environment that is not production, it is noted (
Noted · not prod) and nothing is opened. - In production, and when
openIncidentis on, Wardn opens a Wardn incident with Sev 2 for each unresolved issue first seen in that release, up to a limit. Only prod and only new issues from this release open incidents, and an issue is never opened twice. WithopenIncidentoff, the spike is recorded and nothing opens. - When errors return to usual, that is noted too.
As a wave check
A release wave can ask Sentry with a check query:
sentry.error_spike?project=payments-api&environment=prodThe value is how many times the project's errors in the last spikeMinutes are above what the last day expects, so a check that passes below 3 holds a wave while errors are three times the usual. A Sentry that cannot be read is unknown, so the wave waits (fail closed). Add &optional=true and an unreadable Sentry counts as no spike instead. A wave held by errors is recorded as a signal, at most once a few minutes however often the wave asks.
Recent signals
The page lists what Sentry told Wardn, newest first, with what became of each. GET /api/v1/integrations/sentry/signals returns them a page at a time with a cursor, for the last thirty days.
| Result | Meaning |
|---|---|
| Recorded | A release was made in Sentry, or a spike was noted with nothing to do |
| Retried | Sentry could not be reached; the release will be tried again |
| Failed | Sentry refused it, or it ran out of tries |
| Held wave | A wave check read a spike and the wave waits |
| Noted, not prod | A spike in an environment that is not production |
| Noted, below threshold | Errors are back to usual |
| Opened incident | A spike after a release in production opened an incident |
Pause and disconnect
Pausing on the Integrations page stops releases from being recorded and spikes from being read, and a wave check on Sentry fails closed. Nothing else waits on it. Disconnecting removes the connection, its webhook address, its credentials and the mapping. Releases already made in Sentry stay there.
When Sentry is down
Releases go on without being recorded, and are sent when Sentry is back. No spike signals arrive, and Sentry is shown as stale. A wave check on Sentry errors can't be read, so that wave waits unless the check is optional. Pause, test and disconnect work from the Integrations page. See Integration health.