I HATE on-call. That’s why when I decided to start doing my own side-hustle, I wanted to make sure there were no 4 AM wake-ups unless necessary. I have designed a very simple and cheap process for monitoring websites that uses AWS services. The basic process we use is as follows:
When the SNS Topic is alerted, you are sent a message via either SMS or Email (whichever you have configured).
Getting Up and Running
I’ve created a simple solution to enable this monitoring for each Hosted Zone. We go into Route 53 and add the following comments to each of our Hosted Zones:
<ON_OR_OFF>;<SUBDOMAIN>;<AVAILABILITY_HOURS> e.g. on;www;24x7
ON_OR_OFF: lowercase “on” or “off”. If set to “on”, the script will monitor your website.
SUBDOMAIN: the subdomain to monitor. E.g. if my subdomain is www and my Hosted Zone is engi.fyi, then it will check the URL https://www.engi.fyi/.
AVAILABILITY_HOURS: Not yet implemented.
Installing the Monitoring System
- Install Terraform.
- Run the following commands:
git clone https://github.com/engi-fyi/aws-www-monitoring.git cd aws-www-monitoring/ terraform init terraform apply
- Create a subscription in the SNS Topic that should have been created (default: web_monitoring).
That is it, you’re all done! You will receive an initial ALARM text but within five minutes you should receive the OK text (unless of course your site is down).
In most circumstances for simple websites, I would use Route 53 Health Checks. However, I designed this solution as a simple project that would enable someone to fork and get started on some complex monitoring. There are some websites that need to perform specific checks on APIs and this Lambda-based solution provides the framework for that to occur.
If you have any questions or problems, or you’d like to offer some suggestions for future content, please contact me on Twitter @stophammotime.