brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ping Healthchecks.io by slug and add create=1 to make the check on the fly

Healthcheck
~/tips/tip-healthchecks-slug-create-autoprovision

curl -m 10 --retry 5 "https://hc-ping.com/my-ping-key/srv01?create=1"

Creates a missing Healthchecks.io check on its first ping, with default settings.

Clicking a new check together for every machine gets old fast. Healthchecks.io can create the check itself the first time a job pings it, as long as you use a slug URL instead of the UUID one.

curl -m 10 --retry 5 "https://hc-ping.com/my-ping-key/srv01?create=1"

The URL has two parts you pick yourself: the project’s Ping Key and a slug, here srv01. A slug can contain lowercase letters, digits, hyphens and underscores. Healthchecks.io looks up the project by its Ping Key and checks whether a check with that slug exists. If not, it creates it, records the ping and answers 201 Created. If the check exists, you get a normal 200 OK.

Without create=1, auto provisioning is off, and a slug that matches nothing returns 404. The quotes around the URL are a habit worth having, because ? is a glob character in some shells.

It works on all slug endpoints: success, /start, /fail, /log and the exit status form. A script can therefore derive the slug from the hostname:

curl -m 10 --retry 5 "https://hc-ping.com/my-ping-key/$(hostname)?create=1"

Every new machine then registers itself with its first ping. The caveats are in the documentation. Auto-provisioned checks get the default settings: a period of 1 day, a grace time of 1 hour, and all integrations enabled. You can’t set those from the URL, so adjust them in the dashboard or through the Management API. The slug also isn’t guaranteed to be unique, and a request to a slug that matches several checks returns 409 and is ignored. Auto provisioning is also allowed to exceed your account’s check limit temporarily, up to two times the limit, so a full account doesn’t make new machines fail silently. This tip follows the documentation and was not run against a live account.

Further reading: Auto provisioning, Pinging API

Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid

More Healthcheck tips /usr/bin/certbot renew All Healthcheck tips (2) All topics

Link