Easy Uptime Monitoring Tool with Uptime Kuma in Google Cloud Platform
Tags: uptime, deploy, googlecloud, docker
Published: 2021-12-08 09:05:38

Monitoring our things like websites and APIs eventually become one of major task right after we have successfully deployed them. We want to make sure that our services can be online and healthy all the time for users. To get this done, we usually don't want to waste time to develop our own monitoring tool just for ourselves.

Instead, we can use already established online service like UptimeRobot. We can simply register to them, put our URLs that need to be monitored, then we can see how our services performed through provided charts. But just like any third party services, there are always limitations for every free tiers. If we need to have more advanced features, then we pay for paid tier which is kinda waste of money depending of what we actually need. For example, we simply want the uptime checking cycle reduced to some minutes less than five minutes of free tier.

![Kuma repo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jfr58bohzsiq228rpbly.png)

Hence, there is **Uptime Kuma**. This is the best open-source monitoring tool yet I've ever found. It's free to use, inspired by UptimeRobot (much better and simpler), no tiered restrictions and best of all, it's so easy to deploy for ourselves! You can go check their official Github repository [here](https://github.com/louislam/uptime-kuma).

In this post, anyway, I'm about to guide you to how we can easily deploy **Uptime Kuma** to Google Cloud Platform. It's pretty straightforward to what I'm going to demonstrate, if:
- We just need to deploy the tool without using any domain/subdomain
- We want this tool accessible through internet
- We want cheap deployment (yes, I'm not gonna put 'cheapest' since there will always the free way)

Now let's get started!

_Notes: I'm going to use Compute Engine, instead of App Engine Flexible, Cloud Run or any other services that can host a Docker container. For what I have experienced so far, this is the easiest way to go._

## Create a Compute Engine instance with Container Deployment

Uptime Kuma is **stateful**. It stores some persistent data in itself using local SQLite (based on the repo). Hence, they give ways for us to deploy the tool, which one is by deploying Docker container. The official Docker image is ready to deploy, no need for us to install and configure the environments.
However, one step we still need to do before deploying the container is to create a persistent volume. Of course, this is well supported by Compute Engine, but there are something we need to configure.

Now let's create our instance through this button in Compute Engine page.
![Create instance button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ti8eidpp3fjqei4o1ho.png)

Then, we configure our instance like these:
- Give name to our instance and choose location that covered by [GCP's Free Tier](https://cloud.google.com/free/docs/gcp-free-tier#free-tier-usage-limits).
![Name and location](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3mv9m8tb3shhtohez68.png)
 
- Choose machine type that covered by [GCP's Free Tier](https://cloud.google.com/free/docs/gcp-free-tier#free-tier-usage-limits) as well.
![Choose machine type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o774fp1hchnec0tptgfz.png)

- Next, we configure our boot disk type. Click on **CHANGE** button. On the form, choose **Standard persistent disk**, then click **SELECT** button. (This disk type is covered by [GCP's Free Tier](https://cloud.google.com/free/docs/gcp-free-tier#free-tier-usage-limits))

![Boot disk change](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwzo1zsfz9o9rke4umwx.png)

![Standard boot disk](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phzfty0o2cfr5nl2crri.png)

- Scroll down a little bit, you will find this section. Click **DEPLOY CONTAINER** button.
![Deploy container button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56d7ocq40q4xay74ohch.png)
 
- In the shown form, first fill in these fields. We type in the URL of Uptime Kuma's latest image from Docker Hub: `registry.hub.docker.com/louislam/uptime-kuma:1`. Then if you need it, you can check the options here.
![Describe Docker image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3dye2mzdgj7tcxwwl4em.png)

- Scroll down, you'll find this section. Click on **ADD VOLUME**.
![Volume section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5uhn42hkdfs0azd3fqxv.png)

Now before we continue, you can choose one of two options below to create a Volume for our container. Option #1 is using **TmpFS** volume type, Option #2 is using **Disk** volume type.

### Option #1, using TmpFS volume type

- Choose **TmpFS** volume type. Even it is a temporary file storage, based on [Compute Engine documentation here](https://cloud.google.com/compute/docs/containers/configuring-options-to-run-containers#mounting_tmpfs_file_system_as_a_data_volume), it states that: 

> with tmpfs on a Compute Engine container, the volume and its data persist across container restarts and are deleted only on VM restart.

![Volume TmpFS mount](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z88f6m73fms9a51q5zjw.png)

- Click **DONE** and finally **SELECT** button. Skip Option #2 steps below.
![Done volume configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ipwesvle4188finxsn2u.png)

---

### Option #2, using Disk as volume type

- Close the Container deployment form for now. Then, scroll down until you find this advanced section. Click on it and scroll to **Disks** section.
![Advanced section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8z5j0lubanf151jrbytw.png)
 
- Click on **ADD NEW DISK** to open disk creation form. Fill in configuration like below. I simply choose **zonal, blank, standard persistent disk with 10 GB in capacity**. Click **SAVE** button when finished.
![New disk button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2p4zt5x47ot55h6l8v4u.png)
![New disk form](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvlxtihjnqtu2us2mt3x.png)
 
- Now back to steps in Container Deployment form, in Volume mount section, choose **Disk** as volume type. Then pick your just created Disk and fill in other fields like below. Click **DONE** and finally **SELECT** button. Now we can move on to next steps.
![Volume disk mounts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5idefcpcni6t4xkjrlc.png)
 
---

- Further, we have to give our instance a network tag, for example: `allow-kuma`. Soon after we create the instance, we need to configure firewall to this instance. You may also want to configure a static external IP address with **Standard network tier** in this section.
![Network tag](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xttt9eocg9lo8y883fl.png)
 
- Finally, click on **CREATE** button at the bottom of the screen.
![Create button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yjerhgl6fbwvx2mlwmw4.png)
 
## Configure Firewall rule

Now we already have our instance up and running, but we can't access it through its external IP address yet. We need to open port number `3001` to this instance, hence the given network tag.

- Go to Firewall page.
![Firewall menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gim6r4jau1orkutsndod.png)

- Now set these settings. Click **CREATE** when you done.
  - Name: `allow-kuma`
  - Network: _choose the VPC where the Compute Engine instance exists_
  - Target tags: `allow-kuma`
  - Source IPv4 ranges: `0.0.0.0/0`
  - Protocols and ports: Check on **Specified protocols and ports**, then check **tcp** and type in number `3001`.

---

Just like that, our Uptime Kuma already up and ready to use. Open it through the VM's external IP address and concate with port `3001` like so: `http://123.123.13.12:3001`.

![Uptime is running!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fvr13tqvjezkhft64zi.png)

![Uptime is a go!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm7q82m7b5adbm4g23e0.png)

Now, let's see our cost estimation for those configuration. We assume these variables:
- We are using **Standard networking tier**
- We are using Compute Engine instance that covered by [GCP's Free Tier](https://cloud.google.com/free/docs/gcp-free-tier#free-tier-usage-limits).
- Monthly network egress comes from our instance based on per minute basis pings for 7 monitors is roughly around 0.5 GiB.

You can refer to this [Google Cloud pricing calculator estimate link](https://cloud.google.com/products/calculator#id=ab713e64-ab89-4258-8fac-c7566e1c93a4)

![Cost estimate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/idxburfaim5heowfbdkb.png)
 
We are only incurred cost around **USD 0.44** per month for a rich features monitoring tool! Now that's cheap 💰💰

---

That's it for this post. Further you can explore Uptime Kuma's features and integrate it with social app like Discord. Also, it provides a customizable status page. They are pretty neat and helpful. Save and share this post if you like!