Skip to main content
By the end of this guide, you’ll have heartbeat monitors tracking your scheduled jobs, with alerts firing when a job stops running on schedule.
  • DevHelm CLI installed or an API token
  • One or more cron jobs or scheduled tasks to monitor

The heartbeat pattern

Standard monitors work by checking your service outbound. For cron jobs, the pattern is reversed — your job pings DevHelm after each successful run. If DevHelm doesn’t receive a ping within the expected window, it opens an incident.

Set up a heartbeat monitor

1

Create the monitor

devhelm monitors create \
  --name "Nightly Backup" \
  --type HEARTBEAT \
  --expected-interval 86400 \
  --grace-period 3600
Config fieldValueMeaning
expectedInterval86400Job runs every 24 hours
gracePeriod3600Allow 1 hour of slack before alerting
2

Get the ping URL

devhelm monitors get <monitor-id>
Copy the pingUrl from the response.
3

Add the ping to your job

Add a curl at the end of your script:
#!/bin/bash
set -e

# Your job logic
pg_dump mydb > /backups/nightly-$(date +%Y%m%d).sql
aws s3 cp /backups/nightly-$(date +%Y%m%d).sql s3://backups/

# Ping DevHelm on success
curl -fsS -o /dev/null https://api.devhelm.io/api/v1/heartbeat/<token>
Using curl -fsS ensures the ping is only sent on HTTP success. If the script fails (set -e), the curl never runs and DevHelm eventually alerts.

Common intervals

JobexpectedIntervalgracePeriod
Every minute6030
Hourly3600300 (5 min)
Daily864003600 (1 hour)
Weekly60480086400 (1 day)

Advanced patterns

Add a post-completion container or use a completions-based Job with a sidecar:
apiVersion: batch/v1
kind: CronJob
metadata:
  name: nightly-backup
spec:
  schedule: "0 2 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: backup
              image: myapp/backup:latest
              command: ["/bin/sh", "-c"]
              args:
                - |
                  /scripts/backup.sh && \
                  curl -fsS -o /dev/null https://api.devhelm.io/api/v1/heartbeat/$HEARTBEAT_TOKEN
              env:
                - name: HEARTBEAT_TOKEN
                  valueFrom:
                    secretKeyRef:
                      name: devhelm-heartbeats
                      key: nightly-backup
          restartPolicy: OnFailure
For workers that process queues continuously, add a periodic heartbeat in the main loop:
import requests
import time

HEARTBEAT_URL = "https://api.devhelm.io/api/v1/heartbeat/<token>"
HEARTBEAT_INTERVAL = 300  # 5 minutes

last_heartbeat = 0

while True:
    message = queue.receive()
    process(message)

    if time.time() - last_heartbeat > HEARTBEAT_INTERVAL:
        requests.post(HEARTBEAT_URL, timeout=5)
        last_heartbeat = time.time()
Define all heartbeat monitors in a single YAML file:
version: "1"
monitors:
  - name: Nightly Backup
    type: HEARTBEAT
    config:
      expectedInterval: 86400
      gracePeriod: 3600
    tags: [infrastructure]

  - name: Hourly Report Generation
    type: HEARTBEAT
    config:
      expectedInterval: 3600
      gracePeriod: 300
    tags: [reporting]

  - name: Weekly Cleanup
    type: HEARTBEAT
    config:
      expectedInterval: 604800
      gracePeriod: 86400
    tags: [maintenance]
Always use set -e or equivalent error handling so the ping is skipped when the job fails. This way DevHelm catches both “job didn’t run” and “job ran but failed” scenarios.

Next steps

Heartbeat reference

Full heartbeat configuration and assertions.

First alert

Get notified when a heartbeat goes silent.

Monitoring as Code

Manage all heartbeat monitors in YAML.