Skip to main content

Heartbeat

Create heartbeat monitors for job and cron health checks
2 min read

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 monitor
  • period (Number) - Expected period between pings in seconds

Optional Arguments#

  • grace (Number) - Grace period in seconds before alerting. Default: 0
  • call (Boolean) - Enable phone call notifications. Default: false
  • sms (Boolean) - Enable SMS notifications. Default: false
  • email (Boolean) - Enable email notifications. Default: true
  • push (Boolean) - Enable push notifications. Default: true
  • heartbeatGroupId (Number) - Heartbeat group ID
  • policyId (Number) - Escalation policy ID
  • paused (Boolean) - Whether the heartbeat is paused. Default: false
  • sort_index (Number) - Sort index for ordering

Attribute Reference#

  • id (String) - The heartbeat ID
  • url (String) - The unique URL to ping
  • status (String) - Current heartbeat status (up, down, paused)
  • createdAt (String) - Creation timestamp
  • updatedAt (String) - Last update timestamp
  • lastPingAt (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 FrequencyPeriodGraceUse Case
Every 5 min300s60sFrequent health checks
Hourly3600s300sRegular maintenance
Every 6 hours21600s1800sPeriodic sync jobs
Daily86400s3600sDaily backups
Weekly604800s7200sWeekly 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: