# Heartbeat monitoring for cron jobs and services

> A cron job or service sends a POST to the Upstat API after each run. If the signal does not arrive in time, the monitor goes DOWN and sends an alert.

This type checks in the opposite direction: Upstat does not watch your server, it waits for a signal from it. It suits backups, cron jobs and workers that have no address anything could connect to.

## How it works

1. When you create a heartbeat monitor you get a secret key. It can be rotated in the dashboard at any time.
2. At the end of a successful run, your job sends a POST request to the address containing this key. No header or request body is needed, the key in the address is enough.
3. Every received signal is recorded as a successful check.
4. Every minute Upstat goes through the heartbeat monitors. If more than 1.5 times the monitor interval has passed since the last signal, the monitor is marked DOWN.

## What you set

A heartbeat monitor has no configuration fields of its own. Two things matter.

| What you set | Where to set it |
|---|---|
| **Monitor interval** (`interval_seconds`): How often the job reports. Set it to the job schedule, for example 300 for a cron that runs every 5 minutes. The evaluation uses 1.5 times this value, so one delay of a few seconds does not raise an alarm. | Dashboard and REST API |
| **Heartbeat key** (`heartbeat_key`): A random string that is part of the address. Anyone who knows the key can send the signal, so keep it secret. If it leaks, rotate it. | Dashboard and REST API |

## Example: a backup in cron

The signal is sent only when the backup finishes successfully, thanks to the && after the command. If the backup fails or cron does not run at all, no signal arrives and the monitor goes DOWN. Replace HEARTBEAT_KEY with the key from your monitor.

Crontab entry

```
*/5 * * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 -X POST https://upstat.sk/api/v1/heartbeat/HEARTBEAT_KEY
```

Upstat response when a signal is received

```
{
  "message": "Heartbeat prijatý.",
  "monitor": "MONITOR_ULID",
  "received_at": "2026-01-01T10:00:00+00:00"
}
```

## What counts as a failure

- More than 1.5 times the monitor interval has passed since the last signal.
- The monitor has never received a signal and twice its interval has passed since it was created.

## What happens on failure

- The monitor state changes to DOWN and your alert rules run: Slack, Discord, Telegram, email, SMS, push, webhook or ntfy.
- A missed heartbeat does not create an incident automatically. If you want one on the status page, you create it by hand.
- When the signal arrives again, the monitor returns to UP and a recovery message goes out.
- If the monitor is linked to a status page component, its state shows up there too.

## How it works with ignore blips

A short outage does not have to mean DOWN right away. For each monitor you can set state stabilization. Upstat decides it when it processes check results, not the checker.

- `consecutive_failures`: How many checks in a row must fail before the monitor is marked DOWN. For example 3 means three failures in a row.
- `min_down_seconds`: How long the failing has to last before the state changes to DOWN.
- `min_up_seconds`: How long everything has to be fine after an outage before the monitor goes back to UP. It protects against rapid flapping.

For a heartbeat monitor, DOWN is decided separately, by the window of 1.5 times the interval, and the consecutive_failures and min_down_seconds settings do not apply to it. The interval sets the tolerance. The return to UP goes through the normal evaluation, so min_up_seconds applies.

[How monitoring works](https://upstat.sk/en/how-monitoring-works)

## Limits by plan

The shortest allowed interval between checks depends on the plan. The numbers are read straight from the plan settings.

| Plan | Shortest check interval |
|---|---|
| Hobby | 120 s |
| Starter | 60 s |
| Pro | 30 s |

## Questions about this type

### Do I need an API token to send the signal?

No. The address with the heartbeat key stands on its own and needs no login or Authorization header.

### What happens if I send a signal to a wrong key?

Upstat answers with a 404 error and the signal is not recorded. The same applies to a disabled monitor.

## Other monitor types

- [Website](https://upstat.sk/en/monitors/website)
- [SSL certificate](https://upstat.sk/en/monitors/ssl)
- [TCP port](https://upstat.sk/en/monitors/port)
- [API endpoint](https://upstat.sk/en/monitors/api)
- [Docker container](https://upstat.sk/en/monitors/docker)
- [Database](https://upstat.sk/en/monitors/database)
- [How monitoring works](https://upstat.sk/en/how-monitoring-works): The check cycle, outage confirmation and monitor states.
- [Alerting](https://upstat.sk/en/alerting): Rules, thresholds and alert channels.
