Heartbeat Monitoring
Push-based monitoring for cron jobs, batch processes, and scheduled tasks. Get alerted when expected heartbeats are missed.
Overview
Heartbeat monitoring works differently from other health check types. Instead of upti.my reaching out to check your service (pull-based), your service sends periodic signals to upti.my (push-based). If an expected heartbeat is not received within the configured window, upti.my triggers an alert.
This is the ideal monitoring approach for cron jobs, batch processes, scheduled tasks, background workers, data pipelines, and any process that runs on a schedule. These workloads cannot be effectively monitored with pull-based checks because there is no persistent endpoint to probe.
Heartbeat Modes
upti.my supports two ways to use Heartbeats depending on how much visibility your job needs.
| Mode | Best For | Behavior |
|---|---|---|
| Single Heartbeat | Simple cron jobs and one-step scheduled tasks | One ping per run. If the expected ping does not arrive within the configured period plus grace window, the heartbeat becomes unhealthy. |
| Job Chain | Multi-stage jobs, imports, pipelines, and long-running tasks | Each run can send named steps, optionally enforce step order, and validate data attached to each step before the monitor marks the run successful. |
How It Works
- Create a heartbeat check in upti.my and receive a unique ping URL
- Configure your cron job or scheduled task to send an HTTP request to the ping URL after each successful run
- upti.my records each heartbeat and tracks whether they arrive on time
- If a heartbeat is missed (not received within the expected interval), an alert is triggered
Ping URL
Each heartbeat check has a unique URL that your service pings:
https://heartbeats.upti.my/v1/monitors/your-tokenReplace your-token with the unique token assigned to your heartbeat check. You can find this token in your check's configuration page in the upti.my dashboard.
The ingest endpoint accepts GET, POST, and HEAD requests, so you can integrate it from shell scripts, app code, workers, and third-party schedulers.
Sending Heartbeats
Sending a heartbeat is as simple as making an HTTP request to your ping URL. Any HTTP method works, but GET and POST are most common.
Using curl
# Simple heartbeat ping
curl -s https://heartbeats.upti.my/v1/monitors/your-token
# Heartbeat with custom body (e.g., job result)
curl -s -X POST \
-H "Content-Type: application/json" \
-d '{"status":"completed","records_processed":1500}' \
https://heartbeats.upti.my/v1/monitors/your-tokenIn a Cron Job
# Run backup script every day at 2 AM, then ping heartbeat
0 2 * * * /usr/local/bin/backup.sh && curl -s https://heartbeats.upti.my/v1/monitors/your-token💡 Ping on Success Only
Use && in your cron command to only send the heartbeat if the preceding command succeeds. This way, a failed job will also result in a missed heartbeat, triggering an alert for both job failures and jobs that did not run at all.
In Application Code
import requests
def run_scheduled_task():
# Your task logic here
process_data()
# Send heartbeat on completion
requests.get(
"https://heartbeats.upti.my/v1/monitors/your-token",
timeout=10
)Job Chain Steps
When a heartbeat is configured as a job chain, each request can identify which step is being reported by including a step key in the query string.
# Step 1: backup started
curl -s "https://heartbeats.upti.my/v1/monitors/your-token?stepKey=backup_started"
# Step 2: files uploaded
curl -s "https://heartbeats.upti.my/v1/monitors/your-token?stepKey=upload_complete"
# Step 3: verification finished
curl -s "https://heartbeats.upti.my/v1/monitors/your-token?stepKey=verification_complete"💡 Enforce Step Order
For multi-stage jobs, you can require steps to arrive in sequence. This prevents a run from looking healthy when downstream events arrive before required earlier stages.
Validation Rules
Each job-chain step can validate incoming data before accepting the heartbeat as successful. Rules can inspect query parameters, headers, or request bodies.
| Source | Supported Checks |
|---|---|
| Query | Validate values like exit_code or duration |
| Header | Validate metadata such as environment, source system, or auth markers |
| Body | Validate JSON or payload content included with the heartbeat |
Supported operators include equals, not_equals, contains, regex, exists, greater_than, and less_than. Rules can be marked required when they must pass for the step to be accepted.
curl -s -X POST \
-H "Content-Type: application/json" \
-d '{"status":"ok","records_processed":1500}' \
"https://heartbeats.upti.my/v1/monitors/your-token?stepKey=verification_complete&exit_code=0"Timing and Thresholds
Heartbeats are schedule-aware. Beyond the base period, you can tune how forgiving the monitor should be and how quickly it changes state.
| Setting | Description |
|---|---|
| Period | The expected time between successful runs |
| Grace Period | Extra time allowed before a missing run is treated as late or failed |
| Failure Threshold | How many missed cycles are required before the heartbeat is marked down |
| Recovery Threshold | How many successful cycles are required before it returns to healthy |
| Pause | Temporarily disables monitoring without deleting configuration or history |
Response Data
Each received heartbeat is recorded with comprehensive metadata:
| Field | Description |
|---|---|
| Last Heartbeat Timestamp | When the most recent heartbeat was received |
| Time Since Last | Duration since the last heartbeat was received |
| Source IP | IP address that sent the heartbeat |
| User-Agent | The User-Agent header from the heartbeat request |
| HTTP Method | The HTTP method used (GET, POST, etc.) |
| Content-Type | The Content-Type header from the request |
| Headers | All HTTP headers sent with the heartbeat |
| Body | The request body content (if any) |
| Query Parameters | Any query string parameters included in the ping URL |
| Heartbeat Count | Total number of heartbeats received for this check |
| On-Time Status | Whether the heartbeat arrived within the expected interval |
| Latency (ms) | How late or early the heartbeat arrived relative to the expected time |
| Current Step | The active step key for job-chain heartbeats |
| Next Deadline | The next time by which a heartbeat or step is expected |
| Last Success / Failure | Separate timestamps for the most recent successful and failed cycles |
Activity Snapshot
In the heartbeat activity view, upti.my summarizes the current monitor state so you can quickly see what happened most recently.
- Last ping time
- Next deadline
- Last success and last failure
- Current step when the heartbeat uses a job chain
- Status transitions such as healthy, at risk, down, or paused
Common Use Cases
- Cron Jobs - Monitor database backups, log rotation, report generation, and cleanup scripts
- Batch Processes - Track ETL pipelines, data imports, and batch computations
- Scheduled Tasks - Verify that Windows Task Scheduler or systemd timers run on time
- Background Workers - Monitor queue consumers, email senders, and async processors
- Renewal Jobs - Ensure certificate renewals, token rotations, and license checks execute
ℹ️ Rich Heartbeat Data
You can include a JSON body with your heartbeat to record additional context, such as the number of records processed, execution duration, or error counts. This data is stored with the heartbeat and visible in your dashboard for debugging.
⚠️ Network Reliability
If the heartbeat request fails due to a transient network issue, the heartbeat is missed and may trigger a false alert. Consider adding retry logic to your heartbeat pings, especially for critical jobs. A simple retry with a short delay can prevent most false positives.
ℹ️ Recommended Setup Pattern
Use a single heartbeat for short, one-step jobs. Use job chains for any workflow where stage order, completion evidence, or payload validation matters.