Heartbeats: get paged when a cron job or backup stops running
Amonit team · Updated
Short answer: a heartbeat is a dead man’s switch. A cron job, a backup script or your monitoring pings Amonit at a regular interval. When a ping doesn’t arrive in time, Amonit opens an alert for the heartbeat’s team, and that team’s escalation policy pages people as for any other alert. The next ping resolves it. Amonit also answers Opsgenie’s Heartbeat API, so scripts that ping Opsgenie heartbeats only need a new URL and key.
Use it for things that fail by not happening: a nightly backup, a queue consumer, an ETL job, or an Alertmanager Watchdog alert that should keep arriving.
1. Create a heartbeat
An admin opens Heartbeats → Add Heartbeat, sets a name, the interval, the team to page and the priority (default P3), and saves. The heartbeat’s edit page then shows its ping URL.
Choose an interval a little longer than the job’s schedule plus how long the job takes. The check runs on the minute the interval ends and adds no grace time, so a job that starts every hour and runs for 10 minutes needs about 75 minutes.
2. Ping it from your job
Call the ping URL at the end of the job, and only when the job succeeded:
restic backup /data && curl -fsS -m 10 --retry 3 https://yourteam.amonit.dev/api/v1/heartbeats/<token>/ping
GET, POST and HEAD all work. The token in the URL is the only key and fits only this heartbeat, so treat the URL like a password. If it leaks, delete the heartbeat and create a new one.
How it behaves
| New heartbeat | Waits for its first ping. It can’t expire before something has pinged it once, so creating it before the job is set up pages nobody. The list shows Waiting for first ping. |
|---|---|
| Ping | The heartbeat is alive for one more interval, counted from this ping. |
| Ping late | One alert: Heartbeat <name> expired (or your own message), with the priority you chose, sent to the heartbeat’s team. Its details show the heartbeat, the interval, the last ping and when it expired. |
| Still no ping | Nothing more. One missed heartbeat is one alert, not a new page every interval. |
| Next ping | Resolves the alert (timeline: Resolved by Heartbeat ping) and starts counting again. A later miss is a new alert. |
| Disabled | Takes pings and pages nobody. An alert that’s already open stays open until a person resolves it or a ping comes. |
| Enabled again | Waits for the next ping, like a new one, so a heartbeat switched off for a week doesn’t page the moment it’s switched on. |
| Interval changed | Counts from the last ping. |
| Deleted | Stops checking. An open alert stays for a person to close. |
Checks are stored in your instance’s database, so they survive restarts and deploys. A check that came due while the instance’s worker was stopped runs once, as soon as it starts again.
Who sees what: everyone sees the heartbeats, their state and last ping, in the web, the app API and the MCP server. Only admins create, change or delete them and see the ping URL.
Moving from Opsgenie heartbeats
Amonit answers Opsgenie’s Heartbeat API (/v2/heartbeats). A script or tool that pings or manages Opsgenie heartbeats only needs a new address and key:
- Open Integrations → Add Integration, pick the type Opsgenie compatible and the team the heartbeats belong to. Its token is the key. It’s the same kind of integration as for alerts from Alertmanager or Grafana.
- Replace
https://api.opsgenie.com(orapi.eu.opsgenie.com) withhttps://yourteam.amonit.dev/api/opsgenie, and the API key with that token. The header staysAuthorization: GenieKey <key>:
curl -fsS -X POST -H "Authorization: GenieKey <key>" https://yourteam.amonit.dev/api/opsgenie/v2/heartbeats/nightly-backup/ping
- Create the heartbeats in the web, or with Opsgenie’s create call (
POST /v2/heartbeatswithname,interval,intervalUnit, …). Heartbeats aren’t imported from an Opsgenie account.
Supported: ping (GET, POST, PUT, PATCH), create, list, get, update (PATCH), delete, enable and disable, with the request and response fields from Opsgenie’s documentation. We built this from that documentation; it was not tested against a live Opsgenie account.
Where Amonit differs from Opsgenie:
- A ping to a name that doesn’t exist is an error (
404). Opsgenie answers PONG to any name, so a typo in a cron job looks fine there and nothing ever watches the job. Withcurl -f, the job’s own log shows the mistake. - A new heartbeat waits for its first ping and reports
"expired": false. Opsgenie’s example showstruefor a new one. - The default alert message is Heartbeat <name> expired (Opsgenie: <name> is expired).
enabledcan be left out on create, and defaults totrue.- A key of an integration with a team sees and manages only that team’s heartbeats. A key of an integration without a team sees all of them and uses
ownerTeam(by id or name). - Alert tags are kept in the alert’s details. They don’t route the alert.
- Limits per key: 600 pings a minute and 60 other calls a minute. Pings don’t use up what alerts need.
For the rest of the move, see Moving off Opsgenie.
Checked against the product on 6 December 2026. Corrections: [email protected].