Alerting — When Down Needs a Human
By the end of this chapter a failing endpoint produces a message somewhere you will actually see it — and you will understand the counting that decides when. The lab proves the whole lifecycle for real: a dead service, a threshold crossed, one webhook caught in a net built for the purpose, then the service rescued and the resolved message caught behind it.
The shape of an alert
Alerts live on the endpoint they watch, and they are counted, not instant:
endpoints:
- name: gone-service
url: "http://127.0.0.1:8799/"
interval: 10s
conditions:
- "[CONNECTED] == true"
- "[STATUS] == 200"
alerts:
- type: custom
failure-threshold: 2
success-threshold: 1
send-on-resolved: true
description: "the gone service is not answering"
The numbers are the behaviour:
- failure-threshold — how many failed visits in a row before the alert is sent. Default 3. One failure is weather; three in a row is news. The lab set 2 so the lesson would arrive quickly.
- success-threshold — how many successes in a row before an ongoing incident counts as over. Default 2.
- send-on-resolved — whether the recovery also sends a message. Set it: "it fixed itself" is information, and it closes the loop in your chat the way the failure opened it.
- description — your words, carried inside the alert. Write them for the person woken up: what broke, not "healthcheck failed".
Once an alert has fired, further
failures do not re-send it every
interval — Gatus tracks that the
incident is already announced.
(Optional reminders exist —
minimum-reminder-interval, minimum
5 minutes — for incidents that stay
down; documented here, not run in the
lab.)
Providers: where the message goes
The type names a provider, and
providers are configured once, globally,
in the same file:
alerting:
custom:
url: "http://127.0.0.1:8735/alert"
method: "POST"
headers:
Content-Type: "application/json"
body: |
{
"event": "[ALERT_TRIGGERED_OR_RESOLVED]",
"endpoint": "[ENDPOINT_NAME]",
"group": "[ENDPOINT_GROUP]",
"description": "[ALERT_DESCRIPTION]",
"errors": "[RESULT_ERRORS]"
}
There are more than forty built-in
providers — Slack, Discord, Teams,
Telegram, email, PagerDuty, Twilio,
ntfy, Gotify, Matrix, and a long tail —
each with the same pattern: an
alerting: block with that provider's
settings (usually a webhook URL or a
token), and type: <name> on the
endpoints that should use it. This
chapter teaches through the custom
provider, deliberately: it is a plain
HTTP request to any URL you give it,
with placeholders in the body —
[ENDPOINT_NAME], [ENDPOINT_GROUP],
[ALERT_DESCRIPTION], [RESULT_ERRORS]
(the actual failure, in words),
[RESULT_CONDITIONS], and
[ALERT_TRIGGERED_OR_RESOLVED] — which
makes it both the most flexible
provider and the easiest to test,
because anything that can listen can
receive it. What you learn here
transfers: only the destination block
changes when you pick Slack instead.
If a provider is named in an alert but not properly configured above, the alert is quietly ignored — and Gatus tells you so once, at startup. The lab's startup log carries the receipt:
[config.ValidateAlertingConfig] configuredProviders=[custom]; ignoredProviders=[aws-ses clickup discord ... ]
(configured: one. Ignored: the rest of
the catalogue, because the lab set up
only custom.) When an alert "doesn't
work", that line is the first place to
look — chapter 12 has the full order of
checks.
The lab: an alert, caught
The lab's capture server
(gatus-lab/capture.py) does one job:
listen on port 8735 and write down
everything it receives. The dead
endpoint failed its first check at
18:24:31, its second ten seconds later —
and the capture file gained exactly
one entry:
POST /alert
Content-Type: application/json
{
"event": "TRIGGERED",
"endpoint": "gone-service",
"group": "lab",
"description": "the gone service is not answering",
"errors": "Get \"http://127.0.0.1:8799/\": dial tcp 127.0.0.1:8799: connect: connection refused"
}
(Full transcript:
t05-webhook-alert.txt.) Read what the
placeholders became: the event, the
endpoint's name and group, your
description, and the real error from the
failed visit — a message a human can act
on without opening the dashboard. Then
the failures continued — seven were
recorded — and no further messages
came. The threshold counted to two,
spoke once, and held its peace.
Then the lab rescued the service: a
stand-in server was started on port
8799. The next check succeeded, the
success-threshold of 1 was met, and the
capture file gained its second entry —
identical in shape, with "event":
"RESOLVED" and "errors": "", the
errors field empty because there was
nothing left to report (transcript
t06-alert-resolved.txt). Triggered and
resolved: the complete life of an
incident, witnessed end to end.
Testing your own alerts
Borrow the lab's trick before wiring a
real channel: point your provider at
something you control — the capture
script is in gatus-lab/ — and run a
deliberately dead endpoint against it
at a short interval with
failure-threshold: 1. You should see
one well-formed message within an
interval or two. Only when the payload
reads the way you want at 3 a.m. should
the URL become the real Slack webhook
or pager. The check for this chapter is
exactly that: show me the captured
message. If you cannot produce it,
the alerting is not done, whatever the
config file claims.
One repetition-saver, documented here
rather than run: if most endpoints
share the same alert shape, set it once
as the provider's default-alert
(thresholds, description,
send-on-resolved) and endpoints need
only say type:. You must still name
the type on each endpoint — the default
supplies the numbers, not the choice.