upti.my

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.

ModeBest ForBehavior
Single HeartbeatSimple cron jobs and one-step scheduled tasksOne ping per run. If the expected ping does not arrive within the configured period plus grace window, the heartbeat becomes unhealthy.
Job ChainMulti-stage jobs, imports, pipelines, and long-running tasksEach 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

  1. Create a heartbeat check in upti.my and receive a unique ping URL
  2. Configure your cron job or scheduled task to send an HTTP request to the ping URL after each successful run
  3. upti.my records each heartbeat and tracks whether they arrive on time
  4. 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:

Heartbeat Ping URL
https://heartbeats.upti.my/v1/monitors/your-token

Replace 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

Curl Example
# 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-token

In a Cron Job

Crontab Entry
# 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

Python Example
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.

Job Chain Example
# 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.

SourceSupported Checks
QueryValidate values like exit_code or duration
HeaderValidate metadata such as environment, source system, or auth markers
BodyValidate 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.

Validation Example
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.

SettingDescription
PeriodThe expected time between successful runs
Grace PeriodExtra time allowed before a missing run is treated as late or failed
Failure ThresholdHow many missed cycles are required before the heartbeat is marked down
Recovery ThresholdHow many successful cycles are required before it returns to healthy
PauseTemporarily disables monitoring without deleting configuration or history

Response Data

Each received heartbeat is recorded with comprehensive metadata:

FieldDescription
Last Heartbeat TimestampWhen the most recent heartbeat was received
Time Since LastDuration since the last heartbeat was received
Source IPIP address that sent the heartbeat
User-AgentThe User-Agent header from the heartbeat request
HTTP MethodThe HTTP method used (GET, POST, etc.)
Content-TypeThe Content-Type header from the request
HeadersAll HTTP headers sent with the heartbeat
BodyThe request body content (if any)
Query ParametersAny query string parameters included in the ping URL
Heartbeat CountTotal number of heartbeats received for this check
On-Time StatusWhether the heartbeat arrived within the expected interval
Latency (ms)How late or early the heartbeat arrived relative to the expected time
Current StepThe active step key for job-chain heartbeats
Next DeadlineThe next time by which a heartbeat or step is expected
Last Success / FailureSeparate 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.