The Heartbeat resource creates monitors that expect regular "pings" from your jobs, cron tasks, or scheduled processes.
Example Usage#
Basic Heartbeat#
Cron Job Heartbeat#
Short-Interval Heartbeat#
Heartbeat with Policy#
Heartbeat Group#
Argument Reference#
Required Arguments#
name(String) - Name of the heartbeat monitorperiod(Number) - Expected period between pings in seconds
Optional Arguments#
grace(Number) - Grace period in seconds before alerting. Default: 0call(Boolean) - Enable phone call notifications. Default: falsesms(Boolean) - Enable SMS notifications. Default: falseemail(Boolean) - Enable email notifications. Default: truepush(Boolean) - Enable push notifications. Default: trueheartbeatGroupId(Number) - Heartbeat group IDpolicyId(Number) - Escalation policy IDpaused(Boolean) - Whether the heartbeat is paused. Default: falsesort_index(Number) - Sort index for ordering
Attribute Reference#
id(String) - The heartbeat IDurl(String) - The unique URL to pingstatus(String) - Current heartbeat status (up, down, paused)createdAt(String) - Creation timestampupdatedAt(String) - Last update timestamplastPingAt(String) - Last successful ping timestamp
Using Heartbeat URLs#
In Shell Scripts#
In Python#
In Node.js#
In Docker#
Best Practices#
Period and Grace Configuration#
| Job Frequency | Period | Grace | Use Case |
|---|---|---|---|
| Every 5 min | 300s | 60s | Frequent health checks |
| Hourly | 3600s | 300s | Regular maintenance |
| Every 6 hours | 21600s | 1800s | Periodic sync jobs |
| Daily | 86400s | 3600s | Daily backups |
| Weekly | 604800s | 7200s | Weekly reports |
Error Handling#
Monitoring Multiple Environments#
Grouped Heartbeats#
Common Patterns#
Database Backup Monitoring#
Cron Job Monitoring#
API Scheduled Task#
Import#
Heartbeats can be imported using their ID:
Troubleshooting#
Heartbeat Not Receiving Pings#
Causes:
- Incorrect URL
- Network/firewall issues
- Job failing before ping
Solution:
- Verify heartbeat URL is correct
- Test with curl manually
- Add logging to job
False Alerts#
Cause: Grace period too short for job variability
Solution:
Missing Heartbeat Groups#
Error: "Heartbeat group not found"
Solution: Ensure group is created before heartbeats: