How to check uptime and liveness of your API or website
In this guide we will use Skybear.NET to check if our API or website is online, also known as uptime check or liveness check.
Skybear.NET can do much more than just checking for liveness of an API, and we recommend deeper readiness health checks that actually ensure that your API is not only online but also correctly handling requests.
If you still want simple uptime liveness checks, no problem.😅 Continue reading below.
Uptime liveness health check
The following two lines make up a simple uptime health check for the Skybear.NET website, ensuring it’s online and responding with an HTTP status code of 200
.
Deep pings
Even for cases where you find the multi-step readiness health checks excessive, we recommend using deep pings instead.
Expose a /deep-ping
endpoint that will not just return 200
immediately.
Your application should check all the its dependencies and configuration, e.g. access to the database or to your cloud provider, and only then return its response. This will at least ensure that there is nothing obviously broken neither in your uptime, nor in your application’s configuration.
Still not as comprehensive as actually exercising some business logic, but it’s a nice way to get more feedback.
Scheduled runs
Now that we have a script to check uptime liveness, we can create a scheduled cron trigger to make sure it runs continuously every day and sends us an email when it fails.
After you create the Skybear.NET script with the appropriate content, navigate to its Settings tab, and configure a Scheduled Cron trigger with the cron expression */15 * * * *
so that it runs every 15 minutes, every day, forever.
You can configure the trigger to notify you by email when any of the script assertions fail.