Skip to main content
Before diving into specific examples, remember these key principles:
  1. Ping only on success - Only send pings when your task completes successfully
  2. Include timeouts - Prevent hanging requests that could block your job
  3. Add retries - Handle temporary network issues gracefully
  4. Position correctly - Place pings at the very end of your success path
  5. Use source headers - Help identify which system sent the ping
All examples include timeout and retry configurations to prevent false alerts caused by temporary network issues. Always include these safeguards in production implementations.

Shell Scripts and Command Line

Basic cURL Examples

The most common way to ping heartbeat monitors from shell scripts:

wget Alternative

If cURL isn’t available, use wget instead:

Platform-Specific Integrations

Heroku Scheduler

Monitor Heroku scheduled tasks:

Render Cron Jobs

For Render cron job services:

Railway Cron Jobs

Similar pattern for Railway scheduled deployments:

Kubernetes Cron Jobs

Basic CronJob with Heartbeat

Advanced CronJob with Sidecar

For more complex scenarios, use a sidecar pattern:

Node.js and JavaScript

Built-in HTTPS Module

Using Axios

Fetch API (Modern Browsers/Node.js 18+)

Vercel Cron Jobs

Monitor your Vercel cron jobs across different routing patterns:

Python Examples

Using Requests Library

Django Management Commands

PowerShell Examples

For Windows environments and Azure functions:

Advanced Patterns

Conditional Heartbeats

Sometimes you only want to ping under certain conditions:

Multi-Step Job Monitoring

For complex jobs with multiple phases:

Troubleshooting

Common Issues

Problem: Pings fail due to network timeouts or slow connections.Solution: Always configure timeouts and retries:
Problem: Pings are ignored due to blocked user agents.Blocked user agents: Twitterbot, Slackbot, Googlebot, Discordbot, Facebot, TelegramBot, WhatsApp, LinkedInBotSolution: Use custom user agents:
Problem: Using unsupported HTTP methods.Supported: GET, POST
Not supported: PUT, DELETE, PATCH
Solution: Stick to GET or POST:
Problem: Pings sent even when job fails.Solution: Structure your code correctly:

Testing Your Implementation

Before deploying, test your heartbeat integration:
  1. Manual ping test: Use the Checkly UI to send manual pings
  2. Timeout test: Temporarily block network access to verify timeout behavior
  3. Failure test: Force your job to fail and confirm no ping is sent
  4. Retry test: Add temporary network delays to test retry logic
Start with a short grace period (like 5 minutes) while testing, then increase it to your production requirements once you’re confident in the timing.