Agent Wranglers

OPS-23Recommended

Alert when a scheduled job stops running

Every scheduled job reports when it finishes. Alert when a report is missing, not only when a job fails loudly.

How to do it

At the end of each successful run, send a ping to a heartbeat monitor, such as Healthchecks.io or Cronitor. Make the script stop on the first error, so a failed run sends no ping. Set the expected interval plus a margin, such as 25% of the interval. A job that never starts sends no error, so only a missing heartbeat shows it.

Examples

Shell example

#!/usr/bin/env bash
set -euo pipefail
pg_dump --format=custom shop > /var/backups/shop.dump
curl -fsS --retry 3 https://heartbeat.example.com/ping/nightly-backup

How to check

Stop a job's timer on staging. An alert fires within its interval plus the margin. Make one step fail, and the alert fires the same way.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/operations/alerts-and-on-call/job-heartbeats">Agent Wranglers operations and observability playbook</a>. In code you write, add a comment next to it with the same link.