Expected Reading Time: 5 minutes

What is Healthchecks.io?

Healthchecks.io is a monitoring service specifically designed to monitor periodically executed tasks (like cronjobs). It works by waiting for a "sign of life" from your scripts - a so-called "ping". When a scheduled script is successfully executed, it sends a ping to Healthchecks.io. If this ping fails, the tool knows that something has gone wrong and sends you a notification. This simple but effective method ensures that you are always in the picture if a process does not work as expected.

The technical basics of Healthchecks are:

  • Python 3.10+
  • Django 4.2
  • PostgreSQL or MySQL

Healthchecks is licensed under the BSD 3-clause license and is therefore open source software.

The tool is available as a hosted service at https://healthchecks.io/ is available. A Dockerfile and ready-made Docker images are also available.

Why use Healthchecks.io?

Reliable monitoring

Healthchecks.io is ideal for ensuring that important tasks such as database backups, system updates or other automated scripts are actually executed.

Flexibility and integration

You can use Healthchecks.io among other things through Apprise integrate with various notification services such as email, Slack, Discord and many others. This provides flexibility and allows you to receive alerts in the way that makes the most sense for you. For added security, Healthchecks offers support for two-factor authentication (2FA) with WebAuthn.

Simplicity and accessibility

With its user-friendly interface, Healthchecks.io is easy to use and set up. You don't need in-depth IT knowledge to benefit from this tool.

Setting up Healthchecks.io

The setup is simple and can be completed within 10 minutes. Especially when you only have to enter the following via copy-paste.

Step 1: Setup via Docker

You can set it up as usual using Docker. All you need to do is install Docker and, ideally, Docker Compose. You can find further setup options on the GitHub page of the tool. For the example we use the optimized and maintained for Linux servers Version of Healthchecks.iothat linuxserver.io provides.

The following docker-compose.ymlthat need to be used. Below the block, I go into the environment variables.

services:
  healthchecks:
    image: lscr.io/linuxserver/healthchecks:latest
    container_name: healthchecks
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Berlin
      - SITE_ROOT=
      - SITE_NAME=Healthchecks
      - [email protected]
      - SUPERUSER_PASSWORD=strongPassword
      - ALLOWED_HOSTS= #optional
      - APPRISE_ENABLED=True #optional
      - CSRF_TRUSTED_ORIGINS= #optional
      - DEBUG=True #optional
      - DEFAULT_FROM_EMAIL= #optional
      - EMAIL_HOST= #optional
      - EMAIL_PORT= #optional
      - EMAIL_HOST_USER= #optional
      - EMAIL_HOST_PASSWORD= #optional
      - EMAIL_USE_TLS= #optional
      - INTEGRATIONS_ALLOW_PRIVATE_IPS= #optional
      - PING_EMAIL_DOMAIN= #optional
      - RP_ID= #optional
      - SECRET_KEY= #optional
      - SITE_LOGO_URL= #optional
    volumes:
      - /path/to/healthchecks/config:/config
    ports:
      - 8000:8000
      - 2525:2525 #optional for SMTP pings
    restart: unless-stopped

Step 1: Create account

First docker-compose.yml and insert the code from above. All values that begin with #optional are not required for installation. SITE_ROOT must be the address under which Healthchecks will be called up later. Assuming your server is running at IP address 192.168.178.44. Then enter SITE_ROOT http://192.168.178.44:8000 (unless you change the port, otherwise of course enter this). This is ultimately the top-level URL of the website and the port on which it is being listened to.

With SITE_NAME you enter what should be the name of the page in the browser. This can simply be Healthchecks. Logically SUPERUSER_EMAIL and SUPERUSER_PASSWORD for the initial user. We would also recommend using Apprise for the full range of notification services through APPRISE_ENABLED=True switch on. You can look up the rest for advanced options such as email pings on the GitHub page.

Step 2: Setting up a check

After logging in with your newly created superuser, you can set up a new "check". This is a type of monitoring job for a specific script or task.

Step 3: Configuring the notifications

Configure how and when you want to be notified if a script is not executed as planned. You can choose between various services such as email, Slack or Discord. Of course, you need to set up a configuration for this, but this is also relatively simple and explained directly in the app.

Step 4: Integrate into your scripts

Integrate the generated ping URL into your scripts. This is often as simple as adding an HTTP request at the end of your script. For example, you go to the bash script and check whether the last command was successful and then ping the given address.

Example:

if [ $? -eq 0 ]; then
    curl -fsS -m 10 --retry 5 -o /dev/null http://192.168.178.44:8000/ping/a192ec54-ab0a-4944-9d2b-4a1c378400a0
fi

This would be an excerpt from a shell script that checks whether the last command was successful, i.e. whether a 0 was output. Otherwise, a 1 would be output and the if statement would not apply and the ping would not be sent due to the error and Healthchecks would notify us.

This completes the setup and you can monitor your scripts.

YouTube video implementation

Conclusion

Healthchecks.io is a powerful yet easy-to-use tool for anyone who wants to effectively monitor their automated processes and scripts. It offers a great mix of flexibility, reliability and ease of use. With Healthchecks.io, you can ensure that your automated tasks run smoothly and that you are informed immediately in the event of problems.

The display of the products was implemented with the affiliate-toolkit plugin.
Categories: Docker

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_US