Monitoring as Code: Learn more about the Heartbeat Monitor Construct.

What are Heartbeat Monitors?
Heartbeat monitors are passive monitoring checks that wait for your automated tasks to report their successful completion. When your scheduled job, backup script, or cron job finishes successfully, it sends a simple HTTP request (a “ping”) to Checkly to confirm it ran. If Checkly doesn’t receive a ping within the expected timeframe, it triggers alerts to notify you that something may have gone wrong. Heartbeat monitors are perfect for:- Backup jobs and data exports
- ETL processes and data imports
- Scheduled maintenance scripts
- Newsletter and email campaigns
- Database cleanup tasks
- File processing workflows
How Heartbeat Monitoring Works
The heartbeat monitoring process is straightforward. Once created, your heartbeat monitor provides a unique ping URL. Your tasks should make an HTTP GET or POST request to this URL when they complete successfully.- Create a monitor - Set up a heartbeat monitor with your expected ping frequency
- Get your ping URL - Checkly provides a unique URL for your task to ping
- Add the ping - Include a simple HTTP request in your task’s success path
- Monitor results - Checkly tracks pings and alerts you when they’re
Always add the heartbeat ping at the very end of your task, after all critical operations have completed successfully. This ensures you only get “success” pings when your job actually finished.
Grace Period
The grace period provides extra time before alerting, compensating for natural variance in job execution times: Common grace period examples:- Daily backup at 2 AM with 30-minute grace → Alert if no ping by 2:30 AM
- Weekly report on Fridays with 4-hour grace → Alert if no ping by end of Friday
- Hourly sync job with 5-minute grace → Alert if ping is more than 5 minutes late
Understanding Grace Periods
Understanding Grace Periods
Grace periods compensate for natural variance in job execution times. For example:
- Daily backup at 2 AM with 30-minute grace → Alert if no ping by 2:30 AM
- Weekly report on Fridays with 4-hour grace → Alert if no ping by end of Friday
- Hourly sync job with 5-minute grace → Alert if ping is more than 5 minutes late
- Normal variance in your job execution time
- Acceptable delay before you need to know about failures
- Time needed for any retries or recovery processes
Timer Behavior
Timer Behavior
The heartbeat timer works predictably:
- First ping starts the timer - When you send the first ping, monitoring begins
- Each ping resets the timer - Every successful ping resets the countdown
- Alerts also reset the timer - After an alert fires, the timer restarts
- Deactivation resets everything - Pausing and resuming a monitor restarts timing

How to Choose the Right Grace Period
How to Choose the Right Grace Period
Consider Your Job Variance
- How much does your job’s runtime vary?
- Account for network delays and system load
- Include time for any retry logic
- Too short: False alerts during normal delays
- Too long: Slower failure detection
- Start conservative, adjust based on experience
Metrics
Heartbeat monitors provide different metrics and insights than other types of checks and monitors:- Ping History: Timeline of when pings were received
- Missed Pings: Gaps where expected pings didn’t arrive
- Alert Timeline: When alerts were triggered and resolved
- Source Tracking: Which systems or processes sent pings
Remember: Heartbeat monitors detect when jobs fail to complete, but they can’t tell you why a job failed. Combine heartbeat monitoring with application logging and error tracking for complete observability.
Manual pings
You can manually send pings via the Checkly UI. Use this to start the check timer when a check is first created or to silence alarms.

How does the timer work?
The check timer starts when it receives its first ping and will reset after each ping or triggered alert. If you have a check that expects a ping every 60 minutes starting at 09:30, and it receives a ping at 10:00, it will reset the timer to expect a ping before 11:00. If the check does not receive a ping before 11:00 plus the configured grace period, it will trigger any configured alerts.Every ping or triggered alert will reset the timer of the next expected heartbeat ping.

When a check is deactivated and activated again, the timer will start when the check is saved. This is also the case when changing the period of a check.
Best Practices
Always include timeout and retry options:Troubleshooting
Monitor Not Starting
Monitor Not Starting
- Issue: Timer doesn’t start after first ping
- Solution: Check that the monitor is activated and the ping URL is correct
False Alerts
False Alerts
- Issue: Getting alerts even when job runs successfully
- Solution: Increase grace period or check if ping is being sent correctly
Missing Pings
Missing Pings
- Issue: Job runs but no ping is received
- Solution: Verify network connectivity and ping URL accessibility
Timer Reset Issues
Timer Reset Issues
- Issue: Timer doesn’t reset after successful ping
- Solution: Check ping method (GET/POST) and ensure no network timeouts