Heartbeat monitor
Monitor cron jobs, background workers, and scheduled tasks by having them ping UptimeWarden instead of the other way around.
A heartbeat monitor inverts the usual direction: UptimeWarden does not reach out to your service, your service reaches out to UptimeWarden. Cron jobs, periodic workers, and backup scripts send a small "I'm alive" ping after each successful run. If the ping does not arrive in time, UptimeWarden alarms.
Classic monitors push their checks (UptimeWarden contacts the target); heartbeat monitors pull (the target contacts UptimeWarden). They are perfect for systems behind firewalls, in isolated networks, or on periodic schedules that an outbound check cannot observe.
How the flow works
The heartbeat loop ties three actors together: your cron, the UptimeWarden ping endpoint, and a grace timer. When a ping does not arrive, the timer expires and an incident opens.
sequenceDiagram
autonumber
participant Cron as Cron / Worker
participant API as UptimeWarden Ping API
participant Timer as Grace Timer
participant Alert as Alert Pipeline
Cron->>API: POST /api/heartbeat/<token>/ping
API-->>Timer: reset(now + interval + grace)
Note over Timer: waits for the next ping
Cron-->>API: (ping skipped, script failed)
Timer->>Alert: timer expired → incident "down"
Alert-->>Cron: email / SMS / on-call rotation
When to use
- Nightly backup: A cron at 02:00 runs
pg_dump. You want to know if it did not run, but you do not want to expose the backup server to the internet. - Weekly reports: A scheduled job generates a Monday-morning report at 09:00. If Monday is late, you want to hear about it.
- Queue workers: A worker pings every 5 minutes; if it stops, you alert 10 minutes later.
- Air-gapped systems: Isolated servers with outbound HTTPS only: heartbeats fit; inbound checks do not.
Creating a monitor
-
On the Monitors page choose Add monitor → type: Cron & Background Jobs (Heartbeat; some types sit under Show 7 more types)
-
Settings:
- Display name: e.g.
Nightly Backup - Postgres - Expected interval: Expected ping cadence. The list has nine presets from 1 minute to weekly (
dailyfor a daily backup). - Grace period (sec): Lateness tolerance (e.g. 600 = 10 minutes). The monitor goes down if no ping arrives within
interval + grace. Grace presets are available too.
- Display name: e.g.
-
Save with Start monitoring. UptimeWarden gives you a unique ping URL. The create confirmation screen shows the URL and a Copy ping URL button. If you lose it, you find the URL, a ready-to-paste curl command and a crontab line in the monitor's detail page under Configure → Request. You can change the interval in seconds (60 s to 30 days) under Configure → General in the Expected ping every (seconds) field.
https://app.uptimewarden.online/api/heartbeat/<token>/ping
- Append this URL to your cron script.
Sending pings
curl (most common)
# crontab line
0 2 * * * /usr/local/bin/backup.sh && curl -fsS https://app.uptimewarden.online/api/heartbeat/TOKEN/ping
The && ensures the ping fires only if the backup exits successfully. If the backup fails, no ping goes out, and the monitor alarms when the grace period expires.
Python
import requests
requests.post("https://app.uptimewarden.online/api/heartbeat/TOKEN/ping", timeout=5)
Node.js
await fetch("https://app.uptimewarden.online/api/heartbeat/TOKEN/ping", { method: "POST" });
Bash wrapper (ping on success only)
For long-running jobs, wrap the work and ping only when it finishes successfully. A successful ping resets the timer. Not pinging on failure triggers the alarm when the grace period runs out; if you want to report the failure immediately, use the failure signal below.
#!/bin/bash
HB_URL="https://app.uptimewarden.online/api/heartbeat/TOKEN/ping"
# the real work
./run-backup.sh
EXIT=$?
# ping only on success; skip the ping on failure → alarm when grace expires
if [ $EXIT -eq 0 ]; then
curl -fsS "$HB_URL" >/dev/null 2>&1
fi
exit $EXIT
A successful ping returns 204 No Content. On a transient server error it returns 503; your client can simply retry.
Failure signal
If the job ran but failed, you can say so explicitly. The monitor goes down at the next heartbeat evaluation (every 30 seconds) instead of waiting for interval + grace to run out; the next successful ping brings it back up.
curl -fsS "https://app.uptimewarden.online/api/heartbeat/TOKEN/ping?state=failure&message=backup%20failed"
# or
curl -fsS -X POST https://app.uptimewarden.online/api/heartbeat/TOKEN/fail
state accepts failure, fail, failed and error. You can send the same information in a JSON body: {"state":"failure","message":"..."}. The message becomes the incident's error message and is cut to 500 characters.
What happens when a ping does not arrive?
If no ping arrives within interval + grace, the monitor goes down and an incident opens. The evaluation runs every 30 seconds. From there:
- The silent time counts as downtime. From the moment the deadline passes, UptimeWarden writes one
downcheck result per heartbeat interval (at most once every 30 seconds). The uptime on the dashboard and status pages, and the SLO, count that time as an outage. A failure signal writes the same results. - One ping closes the incident. On other monitors an incident closes after N consecutive successful checks (3 by default). On a heartbeat, a ping already shows the job ran, so one is enough.
- If you resolve the incident yourself. If you resolve it while the job is still silent, the same silence does not alert again. The next ping starts a new stretch: if pings stop again, a new incident opens. A restart on our side does not send a second alert for the same silence either.
- Maintenance windows. If pings stop inside a maintenance window, no incident opens. If the job is still silent when the window ends, the incident opens at the first evaluation after it (within about 30 seconds).
How to pick a grace period
| Scenario | Interval | Grace |
|---|---|---|
| Nightly backup (02:00) | 86400 (24h) | 3600 (1h), backups can drift an hour |
| Worker every 5 min | 300 | 120 (2 min), fast alarm |
| Weekly report | 604800 (7d) | 86400 (1d). Monday can slip |
| Per-minute health ping | 60 | 30 |
Rule of thumb: grace = interval × 20-50%. Too small and network latency produces false alarms; too large and you hear about real problems slowly.
Rate limiting
The heartbeat endpoint accepts up to 120 requests per minute per token and client IP, and up to 600 requests per minute per client IP across all tokens. Normal cron usage stays well below this, but a misconfigured worker pinging more than once a second is rate-limited so it does not flood your account.
What happens when you pause the monitor?
Pause → the system stops expecting pings → no alarms.
Pings received while paused are still recorded. When you resume, the last-ping timestamp is not refreshed: if the last ping is older than interval + grace, the monitor goes down shortly after you resume (within about 30 seconds). Sending a ping after a long pause avoids this.
Security
- The token is the credential: Each monitor has its own token (a new one is a 43-character random string), and anyone who knows the URL can send a ping, so do not share it. Any unknown or malformed token returns the same
404, which never reveals whether a token exists; requests are also rate-limited. - HTTPS end-to-end: HSTS is enforced platform-wide, so browsers and clients upgrade the connection to HTTPS. Always send the ping over
https://. - The ping body is not stored: A successful ping keeps only the timestamp. The
messageof a failure signal (up to 500 characters) is stored as the incident message, and written to the audit log with its IP and user agent; a successful ping writes no audit row. Do not put secrets in the message or the URL.
Compared to HTTP monitor
| Scenario | HTTP Monitor | Heartbeat Monitor |
|---|---|---|
| Is a website / API up? | Yes | No |
| Did the cron job finish? | No | Yes |
| Is the background worker alive? | No | Yes |
| System behind a firewall | No | Yes |
| Periodic report generated? | No | Yes |
FAQ
Q: My script occasionally runs late and I get false alarms. A: Increase the grace period. Alternatively, move the ping to the start of the script ("started"), but that does not prove "finished successfully."
Q: Can I use HTTP Basic Auth on the endpoint? A: The heartbeat endpoint is anonymous, the token is the authentication. No extra layer is needed, and secrets in cron are a pain to manage anyway.
Q: GET or POST? A: Both are accepted, and so is HEAD. POST is semantically correct (there is a side effect, it resets the timer) but practically equivalent.
Related topics
- Other Monitor Types
- Notification Channels
- On-Call & Escalation: route heartbeat alarms to an on-call rotation