Start and finish receipts
One receipt after the job finishes is enough for outcome rules. Add a running receipt at the start when you also want an alert for a job that starts and never ends.
The pair
Use the same request_key for both. The key identifies one execution.
KEY="nightly-$(date -u +%Y%m%dT%H%M%SZ)"STARTED="$(date -u +%FT%TZ)"post() { curl -sS -m 5 -X POST "https://app.crontinel.com/api/v1/ingest/cron" \ -H "Authorization: Bearer $CRONTINEL_INGEST_KEY" \ -H "Content-Type: application/json" -d "$1" || true}
post "{\"request_key\":\"$KEY\",\"command\":\"nightly-import\",\"status\":\"running\",\"started_at\":\"$STARTED\"}"
./nightly-import.shCODE=$?RECORDS=$(cat /tmp/nightly-import.count 2>/dev/null || echo 0)
STATUS=completed; [ "$CODE" -ne 0 ] && STATUS=failedpost "{\"request_key\":\"$KEY\",\"command\":\"nightly-import\",\"status\":\"$STATUS\",\"exit_code\":$CODE,\"started_at\":\"$STARTED\",\"finished_at\":\"$(date -u +%FT%TZ)\",\"outcomes\":{\"metrics\":{\"processed_records\":$RECORDS}}}"exit $CODERules for the pair:
started_atmust be the same in both receipts. A different identity under the same key returns 409.- A finished run (
completedorfailed) cannot be changed or reopened. Use a new key for a retry. - A late
runningreceipt after the finish is ignored. || trueand-m 5keep a monitoring failure from failing the business job.
What each receipt unlocks
| You send | Alert you get |
|---|---|
| Only the finish receipt | Outcome failures (exit code, processed_records). |
| Finish receipt plus a registered schedule | Also: the run never started. |
running plus a registered schedule | Also: the run started and never finished within max_runtime_seconds. |
Fields are listed in the ingest reference.