Skip to content
HookPulse

Migrate from Healthchecks.io to HookPulse

Export your Healthchecks.io checks, turn them into crontab lines and import them into HookPulse in one go.

Updated

1Export your checks

In the settings of your Healthchecks.io project, create a read-only API key. This call saves every check of the project in checks.json.

curl -s https://healthchecks.io/api/v3/checks/ -H "X-Api-Key: $HC_READ_ONLY_KEY" > checks.json

2Turn them into crontab lines

Save this script as hc2crontab.py. Each check becomes one line with its schedule and its name. A period with no cron schedule becomes a comment, and so does a time zone other than UTC.

import json
import sys

# A simple check's period, in seconds, as a cron schedule.
PERIODS = {
    60: "* * * * *",
    300: "*/5 * * * *",
    600: "*/10 * * * *",
    900: "*/15 * * * *",
    1800: "*/30 * * * *",
    3600: "0 * * * *",
    86400: "0 0 * * *",
    604800: "0 0 * * 0",
}

with open(sys.argv[1], encoding="utf-8") as f:
    checks = json.load(f)["checks"]
for check in checks:
    name = check["name"] or check["slug"] or "healthchecks-check"
    schedule = check.get("schedule") or PERIODS.get(check.get("timeout"))
    if not schedule:
        print(f"# by hand: {name}, every {check.get('timeout')} seconds")
        continue
    if check.get("tz", "UTC") != "UTC":
        print(f"# {name} runs in {check['tz']}: set this time zone on the monitor")
    print(f"{schedule} {name}")

3Preview the import

HookPulse creates nothing yet. The answer lists the monitors it would create and the lines it ignored, with the reason. Keep the hp_ token: it owns the new monitors.

python3 hc2crontab.py checks.json > crontab.txt
HP=$(curl -s -XPOST https://hookpulse.net/api/guest -H 'content-type: application/json' -d '{}' \
  | python3 -c 'import json, sys; print(json.load(sys.stdin)["token"])')
echo "$HP"  # keep this token: it owns the new monitors
curl -s -XPOST "https://hookpulse.net/api/import/crontab" -H "X-Guest-Token: $HP" \
  -H 'content-type: text/plain' --data-binary @crontab.txt

4Create the monitors

Send the same file with apply=1. It creates all the monitors or none, and lists the check-in URL of each one.

curl -s -XPOST "https://hookpulse.net/api/import/crontab?apply=1" -H "X-Guest-Token: $HP" \
  -H 'content-type: text/plain' --data-binary @crontab.txt > created.json
python3 -c 'import json; [print(m["name"], m["ingest_url"]) for m in json.load(open("created.json"))["created"]]'

5Point your jobs at HookPulse

In each job, replace the hc-ping.com URL with the check-in URL of the monitor that has the same name.

# before
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://hc-ping.com/YOUR_UUID
# after
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://hookpulse.net/in/YOUR_ID

6Turn on e-mail alerts

Set the address that receives the alerts of each monitor. Use the ID from its check-in URL.

curl -s -XPATCH https://hookpulse.net/api/endpoints/YOUR_ID -H "X-Guest-Token: $HP" \
  -H 'content-type: application/json' -d '{"alert_to":"you@example.com"}'