Observe

Cron monitors

Track scheduled jobs with Sentry SDK check-ins, see missed, failed and timed-out runs, and alert when a job stops running.

A monitor watches one scheduled job: a nightly sync, a billing run, an hourly cleanup. The job reports a check-in when it starts and when it finishes, and axonpush flags a run that fails, runs too long, or never starts. Monitors appear on the Monitors page in the dashboard.

Send check-ins

Check-ins arrive through the Sentry SDK. Point a Sentry SDK at your axonpush DSN (see Coming from Sentry) and wrap the job with the SDK’s cron helper. There is nothing to create first: the first check-in for a slug creates the monitor.

import sentry_sdk

sentry_sdk.init(dsn="https://<public-token>@api.axonpush.xyz/<project-id>")

monitor_config = {
  "schedule": {"type": "crontab", "value": "0 2 * * *"},
  "timezone": "Europe/Berlin",
  "checkin_margin": 5,      # minutes late before the run counts as missed
  "max_runtime": 60,        # minutes in progress before it times out
  "failure_issue_threshold": 2,
  "recovery_threshold": 1,
}

@sentry_sdk.monitor(monitor_slug="nightly-sync", monitor_config=monitor_config)
def nightly_sync():
  ...

The helper sends an in_progress check-in when the job starts and an ok or error check-in when it ends. A single ok or error check-in with no in_progress before it is also accepted and recorded as a finished run.

Only check-ins sent inside a Sentry envelope are supported. Sentry’s older HTTP cron endpoint and crontab-wrapper URL are not, and the axonpush SDKs have no cron helper of their own.

Monitor configuration

The monitor_config on a check-in sets the monitor’s schedule. Every check-in that carries a config replaces the stored one; check-ins without a config leave it alone.

FieldMeaningDefault
schedule.typecrontab or intervalnone
schedule.valueA 5-field crontab expression, or the interval count
schedule.unitFor intervals: minute, hour, day, week, month or year
timezoneIANA zone the schedule runs in. A CRON_TZ= prefix in the crontab wins.UTC
checkin_marginMinutes after the due time before a run counts as missed1
max_runtimeMinutes a run may stay in progress before it times out30
failure_issue_thresholdConsecutive failed runs before the monitor turns failing1
recovery_thresholdConsecutive ok runs before a failing monitor turns ok1

A monitor with no schedule is never marked missed. It still records ok, error and timed-out runs. An invalid schedule is treated as no schedule, so a typo cannot produce false missed runs.

How runs are judged

A background sweep runs about once a minute. It:

  • records a missed run when no run has started by the due time plus checkin_margin. If several due times passed, they collapse into one missed row instead of a backlog.
  • marks a run timeout when it has been in_progress longer than max_runtime.

A run that starts up to checkin_margin minutes early fulfils the upcoming due time, so small clock differences do not cause a missed run.

The monitor’s own status is one of active (no finished run yet), ok, error, missed or timeout. It only changes to a failure status after failure_issue_threshold consecutive failures, and only returns to ok after recovery_threshold consecutive successes. consecutiveFailures shows the current streak.

Monitors are scoped to the environment of the credential that sent the check-in (the DSN’s public token), so nightly-sync in staging and in production are two monitors. The environment the Sentry SDK reports is kept on each check-in as a label but does not change the scope.

In the dashboard

Monitors lists every monitor with its Recent runs strip (the 30 newest check-ins), Last run, Duration and Next due. Open one to see its check-ins with links to the run’s trace, a duration chart, and its Configuration (Schedule, Grace period, Max runtime, Fails after, Recovers after, Failing streak).

From the monitor panel you can:

  • Mute it. Muting stops missed-run tracking and excludes its failures from monitor_failed alerts. Unmuting restarts the schedule from now, so the muted period never turns into a burst of missed runs. Runs already in progress can still time out while muted.
  • Delete it. This is a soft delete; if the job checks in again, the monitor comes back with a fresh state.
  • Create alert, which opens a new monitor_failed alert rule prefilled with this monitor’s slug.

API

# All monitors in production
curl -s "https://api.axonpush.xyz/monitors?environmentId=prod" \
  -H "X-API-Key: $AXONPUSH_API_KEY"

# Check-ins for one monitor, newest first
curl -s "https://api.axonpush.xyz/monitors/$MONITOR_ID/checkins?limit=100" \
  -H "X-API-Key: $AXONPUSH_API_KEY"

# Mute it
curl -s -X PATCH "https://api.axonpush.xyz/monitors/$MONITOR_ID" \
  -H "X-API-Key: $AXONPUSH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"muted": true}'
  • GET /monitors takes appId, environmentId (slug or ID) and limit (default 50, maximum 500). Each monitor carries recentCheckIns.
  • GET /monitors/{monitorId}/checkins pages older with before (RFC 3339) and returns nextBefore when there may be more. limit defaults to 50, maximum 500. Missed runs have a synthetic checkInId such as missed-1763431200.
  • PATCH /monitors/{monitorId} only accepts muted. Schedule settings come from the SDK’s monitor_config, not from the API.
  • DELETE /monitors/{monitorId} soft-deletes.

Reads need observe:read; mute and delete need observe:manage on a key, or the admin role in the dashboard. An API key bound to an app or environment only sees monitors in that scope. Check-ins are kept for 30 days.

Alert on failures

Create an alert rule with metric: monitor_failed. It counts error, missed and timeout runs that finished in the alert window on unmuted monitors. Set service to a monitor slug to watch one monitor, or leave it empty to watch them all:

{
  "name": "nightly-sync failed",
  "metric": "monitor_failed",
  "operator": "gt",
  "threshold": 0,
  "service": "nightly-sync",
  "destinationType": "email",
  "destination": "oncall@example.com"
}