Configuring a status page in the cloud with Statping
Monitor your websites and other servers with an open-source application called Statping. This software has an easy to use web interface to monitor web applications and services.
This service is meant to monitor your applications. In order to accurately monitor the status of my services, this application needs to be running somewhere that is not my network. I will be using Amazon Web Services to host my status page.
Prerequisites
In order to proceed you need access to Amazon Web Services and a system with Ansible installed. Check out my previous post for help installing Ansible.
https://portal.aws.amazon.com/billing/signup#/start
Creating a Linux VM with the AWS console
-
Log into the AWS console at https://console.aws.amazon.com/ and navigate to Services > Compute > EC2
-
Next, select “Launch Instance” to open the instance to create a new virtual machine.
-
Select “Ubuntu Server 20.04 LTS (HVM), SSD Volume Type”
-
Select this image and Choose Instance Type “t2.micro”
-
Select “Review and Launch”
-
Now I recommend using the following settings for the Security Group:
Type | Protocol | Port Range | Source |
---|---|---|---|
SSH | TCP | 22 | MY IP |
HTTP | TCP | 80 | Anywhere |
HTTPS | TCP | 443 | Anywhere |
- Select “Launch”
- Select an existing SSH key pair or create a new key pair to SSH into this system.
- Now In the AWS console EC2 dashboard, find your new instance under Resources > Instances (running)
- Copy the Public IPv4 address and ssh into the instance to ensure you have access:
|
|
- If you are able to log in, run system updates and then reboot the instance.
|
|
Configuring elastic IP and DNS record
In order to receive a certificate from let’s encrypt, your AWS instance needs an elastic IP address that has an associated DNS A record that is publicly resolvable.
Configuring Statping with Ansible
The configuration of statping is performed with an Ansible role. Make sure you have the public IPv4 address or DNS name to connect to your AWS instance. You will also need the private SSH key to access your instance. Then, clone the role:
|
|
Once this role is saved on your system, install the required roles and collections:
|
|
Once all the requirements are installed, create a playbook to execute the role:
|
|
Docker Compose
This role will copy a docker-compose
template to the target system. This template will include an nginx container, a let’s encrypt container, a statping container, and a postgresql database container.
This file is saved as a jinja template so that ansible variables can be injected into the target system. These variables are defined between brackets ex. "{{ variable }}"
|
|
Execute the playbook:
|
|
Once the playbook has run, wait a few minutes and then you should be able to open the web page in your browser by entering the public hostname that matches the DNS record you created.
https://<public_hostname>.example.com
Statping comes with some example services to monitor but you can add your own.
More information:
For more information, see the statping wiki.