Skip to content

Success-run checks

A job can finish with exit code 0 and still have done nothing: an import that read zero rows, a backup of 0 bytes. With success-run checks the job sends numbers together with its success ping, and CronBeat treats the run as failed when a number breaks a condition you set.

A success ping only says that the job reached its last line. Success-run checks add “and the result looks right”.

  • Imports and syncs that must process at least one row.
  • Backups that must have a minimum size.
  • Jobs that count errors and must stay at zero errors.
  • Only for ping monitors. HTTP checks, Kubernetes monitors and GitHub Actions monitors do not support conditions.

Add up to 5 numbers to the ping URL as query parameters named m_<name>. Any ping route works, with GET or POST.

Terminal window
curl -fsS -m 10 "https://api.cronbeat.dev/ping/PING_KEY?m_rows=1280&m_errors=0" > /dev/null
import requests
requests.get(
"https://api.cronbeat.dev/ping/PING_KEY",
params={"m_rows": rows_processed, "m_errors": error_count},
timeout=10,
)
Terminal window
ROWS=$(/scripts/import.sh)
curl -fsS -m 10 "https://api.cronbeat.dev/ping/PING_KEY?m_rows=$ROWS" > /dev/null

Rules for the parameters:

  • The name is lowercase letters, digits and _, starts with a letter, up to 32 characters. Names are case-sensitive: m_Rows is not m_rows.
  • At most 5 per ping. The value is a finite number, at most 1e15 in size.
  • Anything that does not follow the rules is ignored silently. A ping is never rejected because of its metrics.
  • The numbers are stored with the ping and kept as long as other pings (your plan’s history retention).

Conditions belong to a monitor. A condition is a metric name, an operator and a threshold.

Operator Meaning Shown as
gt greater than >
gte greater than or equal >=
lt less than <
lte less than or equal <=
eq equal =
ne not equal !=

A monitor has at most 5 conditions, and each metric and operator pair can be used once. Numbers are compared as exact decimals, so 0.1 + 0.2 is not silently equal to 0.3.

Terminal window
curl -sS -X PUT https://api.cronbeat.dev/api/monitors/MONITOR_ID/assertions \
-H "Authorization: Bearer cb_pat_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '[
{"metric": "rows", "operator": "gt", "threshold": 0},
{"metric": "errors", "operator": "eq", "threshold": 0}
]'

PUT replaces the whole set, GET returns it and DELETE removes it. Details are in the REST API.

When a success ping arrives on a monitor with conditions, CronBeat checks every condition:

  • A number that breaks its condition, or a metric that was not reported at all, is a violation. The second case reads metric 'rows' was not reported.
  • The ping is recorded as a failed run. In the ping history it starts with [assertion failed] rows = 0 (expected > 1).
  • The monitor goes down and an incident opens with the reason failed and the same text as detail. Your channels are alerted like for any failed run.
  • The slow run check is skipped for that run.
  • The next run that satisfies all conditions recovers the monitor and closes the incident.
  • Inside a maintenance window a violation is only logged.
Situation Result
rows > 0 is set and the job sends ?m_rows=0 The run counts as failed: [assertion failed] rows = 0 (expected > 0). The monitor goes down and an incident opens.
The job sends ?m_rows=1280 The run is a normal success.
The job forgets to send m_rows A violation: metric 'rows' was not reported.
The next run reports m_rows=900 The monitor recovers and the incident closes.
The ping has m_Rows=5 or a 6th metric Those parameters are ignored, the ping is accepted.
PUT on an HTTP check or Kubernetes monitor 400.
PUT on the Free plan 403 with plan_limit_exceeded.
The monitor is in maintenance The violation is only logged.
Setting Rule
Metrics per ping 5
Metric name ^[a-z][a-z0-9_]{0,31}$, case-sensitive
Metric value Finite number, up to 1e15
Conditions per monitor 5, each metric and operator pair once
Monitors Ping monitors only
Plans Pro and Enterprise