Before you begin
- A connected agent with the Monitor write permission.
-
A job that can make one outbound HTTPS request with
curl,wgetor any HTTP client.
Create a heartbeat monitor
-
Step 1. Ask your agent for a heartbeat monitor. Give it the expected interval and a grace period.
Prompt textCreate a heartbeat monitor named nightly-backup. It runs every day. Use a one hour grace period. Show me the heartbeat token. -
Step 2. Store the token from the response as a secret, for example
POSTDEPLOY_HEARTBEAT_TOKEN. It starts withhb_and PostDeploy shows it once.
Report a run
Send start before the job and the exit code after it, so a failed job records fail. GET and POST behave the same. The token in the URL is the only authentication, so treat the URL as a secret. No header is needed.
curl -fsS "https://ingest.postdeploy.dev/h/$POSTDEPLOY_HEARTBEAT_TOKEN?state=start"
/usr/local/bin/nightly-backup.sh
curl -fsS "https://ingest.postdeploy.dev/h/$POSTDEPLOY_HEARTBEAT_TOKEN/$?"
state=start- Marks the run as started. It records no check.
state=finish, or no state- Records an Up check. An open incident resolves after two passes in a row.
state=fail- Records a Down check, opens an incident at once, and notifies your alert channels.
Report the exit code
Append the exit code to the URL. 0 records finish. Any other value records fail. The exit code wins over a state parameter.
0 2 * * * /usr/local/bin/nightly-backup.sh; curl -fsS "https://ingest.postdeploy.dev/h/$POSTDEPLOY_HEARTBEAT_TOKEN/$?" > /dev/null
Make retries safe
Add a ping_id when your job retries the request. PostDeploy records one check per ping_id for 24 hours and answers 202 to each duplicate. Use one value per run, not per request.
curl -fsS --retry 3 "https://ingest.postdeploy.dev/h/$POSTDEPLOY_HEARTBEAT_TOKEN/0?ping_id=nightly-$(date +%F)"
A ping_id has 1 to 128 characters: letters, digits, _, . and -.
Missed runs
A received fail is detected at once, because your job reports it. A run that never starts sends nothing, so nothing is detected. Report fail from the job wrapper wherever the job can fail, and use a separate watchdog if a missed run must alert someone.
Warning: PostDeploy records the pings it receives. It does not alert when an expected ping never arrives. After at least one check, a monitor with no ping for twice the interval, and at least 5 minutes, shows Late on the Monitor screen. A monitor that never received a check stays waiting, and a Down monitor stays Down. No incident opens and no alert is sent.
Verify
-
Step 1. Send one ping and read the status line.
Terminal shellcurl -i "https://ingest.postdeploy.dev/h/$POSTDEPLOY_HEARTBEAT_TOKEN" # Expect: HTTP/1.1 202 Accepted -
Step 2. Open Monitor. The monitor row shows a check time. Its detail screen lists the ping under "Recent checks" as Up.
-
Step 3. Send
/1once to test failure. The detail screen shows a Down check and an open incident. Send two passes to resolve it.
Troubleshoot
- A job stopped and no alert arrived
- A missing ping is not detected. Send an explicit fail from the job. After the first check, watch for Late on the Monitor screen.
- A retried ping adds no check
-
The same
ping_idwithin 24 hours is a duplicate. Use oneping_idper run. - The monitor shows Up but the incident is still open
- An incident resolves after two passes in a row. Wait for the next successful run.
- The URL returns 404
- The token is unknown or was reissued. Ask your agent to reissue the token and approve the request in the dashboard.
- Pings return 202 but record nothing
- The monitor is paused or the subscription is inactive. Ask your agent to resume the monitor.
Limits
- A missed run does not open an incident or send an alert.
- The URL token is the only authentication. Anyone with the URL can report a run.
- Reissuing a token is a destructive action. An owner or admin approves it in the dashboard.