Cron and heartbeat monitor
A heartbeat monitor helps you track periodic tasks by expecting regular requests to a unique URL.
If the expected heartbeat is not received within the specified frequency and grace period, it creates an incident and notifies the configured on-call team.
Getting started with heartbeats?
Start with our Introduction to cron job monitoring or Getting started with cron jobs guide.
Step-by-step setup
- Go to Heartbeats → Create heartbeat.
- Name your heartbeat — e.g. "Daily database backup".
- Set the Expect a heartbeat every field to match the frequency of your task.
- Configure the grace period, which is the extra time allowed before an incident is raised if the heartbeat is missed.
- Configure the On-call escalation settings.
- Click Create heartbeat.
- Copy the secret URL on the heartbeat detail page; you’ll need it in your script.
Heartbeat remains pending until the first request
The heartbeat remains in a "Pending" state until the first request is received. The monitoring period begins from the first heartbeat received, and incidents are only raised after the expected frequency and grace period have elapsed.
Setting up a CRON and a background job
In this example, we’re using the cron-job style syntax to schedule a periodic task. Cron allows you to define tasks based on time intervals such as minutes, hours, days, etc.
To monitor a daily database backup, set up a CRON task to execute your job every day at midnight:
The CRON expression 0 0 * * * means the job will run at midnight every day.
Then, include a curl request to the heartbeat URL in your backup script:
Reporting failures
You can explicitly report a failure by appending /fail to the heartbeat URL:
Additionally, you can include an exit code or output when reporting a failure. For example:
This sends both the exit code and the script output to help diagnose the failure.