How to monitor the status of your website for free12 Mar 2021
In a previous blog post, I showed how easy it is to host a personal website for free. In this one, I’ll show how you can monitor it 24x7 and get alerted if it goes down for, you guessed it, free!
To be clear, this website hasn’t ever gone down in the several years I’ve been running it. The beauty of using a service like Gitlab Pages is that you don’t have to worry about managing uptime. You just make changes locally, push them to your Git remote and let them take care of the rest.
Why monitor uptime then? Well, I needed a way to play with Cloudflare Workers, so using them to monitor the uptime of this website seemed like a good idea. Cloudflare Workers allow you to deploy serverless code on their edge nodes around the world instantly without worrying about things like load balancing, auto-scaling, etc.
The entire process took less than an hour and now every two minutes, a Worker running on a Cloudflare edge node somewhere in the world checks if this website is online. If it isn’t, it sends me an alert via Slack and I also have a nice status page over at status.mustafaali.net to track uptime over the last 90 days.
To get started, go to this Github project and click on the Deploy with Workers button. You’ll be prompted to give Cloudflare Workers permission to fork the project and deploy it using Github Actions.
After that, you’ll have to provide an API token for your Cloudflare account so that the Worker can be deployed and it can read/write to key-value storage. You can generate one under the profile section in the Cloudflare dashboard and use the handy template that is provided.
Now, go to
config.yaml and add a monitor for the website you want to track.
Next, change the frequency of the cron job in
wrangler.toml to run every 2 minutes (
*/2 * * * *) instead of every minute (
* * * * *). This will make sure you don’t exceed Cloudflare’s free quota.
Finally, go to the Settings tab in your repo and add your Slack webhook URL as a secret.
Push these changes and let Github Actions deploy the Worker on Cloudflare’s infrastructure. While you wait, create a
CNAME record in your DNS settings to make the status page available on your domain. You can pick any subdomain you like, just set the value as the URL of the Worker you just deployed.
That’s it! In a couple of minutes, you’ll get a Slack notification with the status of your website.
And, the status page will be available at the subdomain you chose in the last step 🎉.