Monitor Your Shit

An informative bear that's easy to set up!

Monitor Your Shit
Photo by Hans-Jurgen Mager / Unsplash

So a lot of the apps I run have a dashboard that lets me check on the status of them. I was thinking of setting up some dashboard that can combine a lot of them together so I only have to go to one website to see them all.

I was thinking of using Nagios because I have experience using it in the past both at home and in a professional environment, but in the spirit of homelabbing I wanted to try something new. So after browsing a few sites I ended up finding a self-hosted solution that sounded like a cute little bear.

What is It Tho?

The basics

Uptime Kuma is a self-hosted monitoring tool that you can run in a container. It can monitor several things from website uptime and certificate status to docker containers and game servers.

Setting up the container is extremely easy. Once you do that you get access to the dashboard where you can configure your different monitors for any of their supported monitors.

The Setup

Here we go

The first thing I did was head over to their Docker Hub page and check through the instructions. Most times you can also go to the GitHub page of a Docker image and you'll get more updated information and even some instructions that aren't on the Docker Hub page.

Here's the quick rundown of what I ran:

docker run -d \
--restart=always \
-p 3001:3001 \
-v /var/run/docker.sock:/var/run/docker.sock:ro
-v /docker/uptime-kuma/data:/app/data \
--name uptime-kuma \
louislam/uptime-kuma```

I left the port the same since I didn't have any other containers that were using that port. I also set the volume to a local folder on the server so I could retain the data. The official documentation stated to create a volume first and then map the volume to the "/app/data" folder, but I just like writing them directly to the filesystem. Keep in mind that if you do the same that they don't recommend using NFS.

In order to monitor docker containers through the socket I had to add the line "-v /var/run/docker.sock:/var/run/docker.sock:ro". You can omit that part if you don't plan on managing the Docker container.

Once the image has been downloaded and the container set up then you can navigate to http://<host>:<port>. In my case since my Docker server is at 10.1.1.30 and I left the port as 3001 I used http://10.1.1.30:3001 to access it.

The First Login

Be gentle

When you first access the page you'll be created with a page asking you to set up your admin account. Once you do that you'll be greeted with the dashboard with no monitors set up. I'll walk through what I did to set up a monitor for this website, but I warn you it's so easy and self-explanatory that you probably won't finish reading this before getting bored.

On the dashboard click on the green Add New Monitor button on the top left. This will bring up the page to add a new monitor where you enter your details. The screenshot shows the details I used to set up a simple uptime monitor for this site.

I left everything at default except for "Friendly Name" and "URL". I also checked the box for "Certificate Expiry Notification" so that it can check the SSL cert and remind me when I need to renew it. There are other settings on that page that you can change depending on your needs, but for this tutorial I'm setting up the most basic of notifications.

Once you click save it'll take you to the monitor and show you current stats. In the screenshot below you can see that currently there's a 100% uptime since there has been no downtime in the second that the monitor started. You can also see the certificate expiration which shows 83 days (shout out to Let's Encrypt!).

Oh No(tifications)

So you can know when your shit's down

Along with monitoring, Uptime Kuma can also alert you when services you monitor are going down. There are several different services that you can use to accomplish this, but we're going with Discord for this one.

Go to the Settings page and click on Notifications. From there you'll add a new one and a window should pop up that looks similar to this.

Click on Notification Type and you can choose what kind of notification you want. In our case, we're choosing Discord.

Now head on over to the Discord server you want to receive the notifications in and click the settings for that channel. From there you're going to click on Integrations and then Webhooks.

Inside of the webhooks click New Webhook and there you can edit the name that the message will be posted as and which channel you want the notifications to be posted to. After that click on Copy Webhook URL and then you'll paste it into the Uptime Kuma monitor page.

In the Setup Notification page use a friendly name that will help you remember what the notification type is. You can also toggle the two options on the bottom to enable it by default when you create a new alert, as well as apply the alert to all monitors that you already have set up.

Fin

gg ez

And that was it! Now you know how to set up a beautiful monitoring system in a container on your own. With a little tinkering you can have a dashboard that looks like this.

Why not try it for yourself? You can do it, I believe in you!

via GIPHY