How to monitor your web service using Statping
Often times we need a certain response to find out whether the server is running well or is experiencing downtime. Many monitoring tools can be integrated with a variety of services today. Some are paid or free. In this article, I want to share one of the lightweight and fast open-source tools. The tool is called Statping. Statping can be integrated with various platforms such as Slack, Email, Mattermost, Twilio, and others. Statping can be used on various operating systems, such as Linux, macOS, and Windows.
Let’s get started!
Prerequisites
You’ll need the following installed on your system:
- Docker
- Docker compose
- DNS
Installing Docker
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group with something like:
$ sudo usermod -aG docker <your-user>
Remember to log out and back in for this to take effect 😄
Installing Docker Compose
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.28.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Apply executable permissions to the binary
$ sudo chmod +x /usr/local/bin/docker-compose
Create a symbolic link to /usr/bin
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Test the installation
$ docker-compose version
docker-compose version 1.28.0, build d02a7b1a
docker-py version: 4.4.1
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
Installing statping
Create a docker-compose file with the following configurations:
version: '2.3'services:nginx:
container_name: nginx
image: jwilder/nginx-proxy
ports:
- 0.0.0.0:80:80
- 0.0.0.0:443:443
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
networks:
- internet
restart: always
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./statup/nginx/certs:/etc/nginx/certs:ro
- ./statup/nginx/vhost:/etc/nginx/vhost.d
- ./statup/nginx/html:/usr/share/nginx/html:ro
- ./statup/nginx/dhparam:/etc/nginx/dhparam
environment:
DEFAULT_HOST: ${LETSENCRYPT_HOST}letsencrypt:
container_name: letsencrypt
image: jrcs/letsencrypt-nginx-proxy-companion
networks:
- internet
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./statup/nginx/certs:/etc/nginx/certs
- ./statup/nginx/vhost:/etc/nginx/vhost.d
- ./statup/nginx/html:/usr/share/nginx/html
- ./statup/nginx/dhparam:/etc/nginx/dhparamstatup:
container_name: statup
image: statping/statping:latest
restart: always
networks:
- internet
- database
depends_on:
- postgres
volumes:
- ./statup/app:/app
environment:
VIRTUAL_HOST: ${LETSENCRYPT_HOST}
VIRTUAL_PORT: 8080
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
DB_CONN: postgres
DB_HOST: postgres
DB_USER: <username_for_db>
DB_PASS: <password_for_db>
DB_DATABASE: <db_name>
NAME: Statping with SSL
DESCRIPTION: This Status Status Page should be running with SSL.postgres:
container_name: postgres
image: postgres:10
restart: always
networks:
- database
volumes:
- ./statup/postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: <password_for_db>
POSTGRES_USER: <username_for_db>
POSTGRES_DB: <db_name>networks:
internet:
driver: bridge
database:
driver: bridge
The file will run Nginx proxy, statping, and automatic SSL using Let’s Encrypt.
Run docker-compose :
$ docker-compose up -d
Then, access the configured statping domain. The statping domain should have SSL installed. The statping dashboard display will appear as shown below.
For how to use the dashboard and integrate statping with other applications, it will be continued in the next part.
See you soon! 👏