Guides

Heartbeats

Watch cron jobs, backups and workers: ping a URL when the job runs and get alerted when the ping is late, or report a failure with /fail.

A heartbeat watches something that runs on its own schedule: a nightly backup, a cron job, a queue worker. The job pings a URL when it finishes; if the ping doesn't arrive in time, you're alerted.

Set one up

  1. In the dashboard choose Heartbeat, name it, and pick Expected every (5 minutes to 1 week) and a Grace period (extra time before it counts as late; 20% of the period by default, between 1 minute and 1 hour).
  2. Copy its ping URL: https://uptenna.com/hb/<token>.
  3. Call it at the end of the job. GET, HEAD and POST all work.
crontab
# crontab: every night at 03:00
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://uptenna.com/hb/<token>
job.js
// Node, at the end of the job
await fetch(`https://uptenna.com/hb/${process.env.UPTENNA_HEARTBEAT}`);

Late, failed and recovered

  • Late: when the last ping is older than the period plus the grace period, an incident opens and you're alerted (heartbeat.late).
  • Failed: ping https://uptenna.com/hb/<token>/fail when the job breaks. The incident opens right away, and stays open until the next successful ping.
  • Recovered: the next successful ping resolves the incident at once and sends a recovery.
terminal
/usr/local/bin/backup.sh && curl -fsS https://uptenna.com/hb/<token> || curl -fsS https://uptenna.com/hb/<token>/fail

The endpoint answers OK (or Failure recorded). An unknown token gets a 404. Treat the URL as a secret: anyone with it can ping. If it leaks, choose New URL on the monitor; the old one stops working at once.

Pausing a heartbeat stops alerts; when you resume it, it gets a full period before it can be late.