Gatus is a health dashboard that gives you the ability to monitor your services using HTTP, ICMP, TCP, and even DNS queries as well as evaluate the result of said queries by using a list of conditions on values like the status code, the response time, the certificate expiration, the body and many others. The icing on top is that each of these health checks can be paired with alerting via Slack, PagerDuty, Discord, Twilio and more.
In this guide, we will configure Gatus as a health dashboard tool using docker compose.
Prerequisites
- Latest version of Docker installed on the system
- Latest version of docker-compose installed
Ensure Docker and docker-compose is installed
Docker allows us to manage applications in the system as containers without worrying about OS dependencies. Ensure that docker is installed in the system. If you are on Ubuntu, checkout How to Install and Use Docker in Ubuntu 22.04. For other OS systems, check docker website on how to go about it.
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Docker Compose is a python application thus it can be installed as a python package using pip. Ensure that you have Latest python and pip on your system before proceeding. On an Ubuntu system, I use this command:
|
|
Then use pip to install docker-compose:
|
|
Confirm that it is installed by checking the version
|
|
Creating Gatus configuration file
We need a config that will let Gatus know what we are monitoring. Gatus uses yaml
Create the directory where we will store our configurations:
|
|
Save the following as config.yaml
. Be sure to update slack url with your slack webhook.
|
|
The alerting
section configures alerting when monitoring thresholds are met.
Gatus supports multiple alerting providers, such as Slack and PagerDuty, and supports different alerts for each individual endpoints with configurable descriptions and thresholds. Note that if an alerting provider is not properly configured, all alerts configured with the provider’s type will be ignored. In this example we are using slack. We are defining a Slack Webhook URL and failure thresholds.
The endpoints defines a list of endpoints and parameters for the endpoints.
The storage section defines data persistence layer. The default database is sqlite but there is a postgres option. I am defining that the database should be in the current path named data.db
.
Running Gatus with docker
We can run the latest version of Gatus using this command:
|
|
If you have a configuration file config.yaml
like defined above, you can use it by running this command:
|
|
That will run Gatus as a docker container and expose gatus port (8080) in the OS. To access head over to http://server_ip:8080.
Creating a docker-compose file
Docker Compose allows us to define the configurations as yaml. This makes it easy to manage the containers and to understand the various parameters.
Create docker-compose.yaml
with this content:
|
|
The above file will will run the latest gatus image twinproduction/gatus:latest
and ensure that it is always restarted even if the container crashes. We are binding the port to our local system then finally binding the configuration file and the database path to the local ./db
directory.
You can then run the container using this command:
|
|
The container will be started and will listen on the local port :8080
(Optional) Adding Nginx virtual host to proxy traffic
It is easier to remember names than server IPs. You can opt to proxy traffic from to Gatus using nginx.
If you are using ubuntu, install nginx using this command:
|
|
Then create gatus configuration file:
|
|
Add this content to the file to allow all traffic from gatus.example.com
to the gatus port:
|
|
Then ensure that Nginx is started and enabled on boot:
|
|
Now you can visit your site using the specified domain.
To enable ssl on your domain, check How to Secure Nginx with Letsencrypt on Ubuntu 20.04/22.04.
Conclusion
In this guide, we were able to set up docker and docker compose and use it to run Gatus which can be used to do health check monitor on sites.