Free cloud-based monitoring to keep an eye on your server's apps and services

Remote Status Monitoring for your Server

General Sep 2, 2022

A few months ago I wrote about how to set up a Google Cloud Platform instance onto which you could install a docker container called Uptime Kuma to monitor the status of services on your server. This is essentially the same but using a service called Fly.io, and while also being free it is arguably more straight forward. Rather than go into the 'why and why not' part of whether this is something you need or should have, let's jump right in.

💡
Advance Warning: A credit card is required to make use of all the free parts of the cloud service we'll be using. It is not charged, but it is required

Prerequisites

  1. The ability to access your server's command line via a terminal or SSH
  2. Sudo/root privileges inside your terminal to edit files

Setting up Fly.io

This section will talk you through the steps needed to set up a connection to fly.io from your terminal, but you can always follow along with their documentation here.

  • Open up a terminal/SSH session to your server and log in with your user (it doesn't need to be an admin)
  • Type the following command:
curl -L https://fly.io/install.sh | sh

When you do this, there's a chance you'll get the following output (or something similar):

flyctl was installed successfully to /var/services/homes/[USERNAME]/.fly/bin/flyctl
Manually add the directory to your $HOME/.bash_profile (or similar)
  export FLYCTL_INSTALL="/var/services/homes/[USERNAME]/.fly"
  export PATH="$FLYCTL_INSTALL/bin:$PATH"
Run '/var/services/homes/[USERNAME]/.fly/bin/flyctl --help' to get started

This might look a little confusing, but is pretty simple.

  • Copy each line that begins with export and run them individually (there will be no printed output)
  • Then type ls -al and enter. You should see that you have a file called .bash_profile OR .bashrc
  • Whichever one you have, you need to edit and paste those two export lines to the end of them
💡
If you don't have either of them, you can create one with the command touch ~/.bashrc, then continue to edit it with vim or nano
  • It will also be helpful to then run source ~/.bashrc (or ~/.bash_profile) to make this persistent
  • Run flyctl auth signup and follow the instructions
  • After that, or if you already have an account, run flyctl auth login and follow the instructions

That's it, you're all signed in and ready to begin making your Uptime Kuma app....

💡
...almost. At this stage, it's a good idea to go to https://fly.io, sign in and input your credit card details so that you can complete the next steps. This is free, and you're not charged for it (at time of writing at least)

Creating your UptimeKuma container on Fly.io

This can be done either via your command line/terminal, or via their app. I'll show you how to use the former.

  • Type flyctl launch --image louislam/uptime-kuma:latest into your cli and press enter
  • Follow the onscreen instructions, bear in mind that the App Name needs to be something unique, and will form the first part of the subdomain URL you'll be given later on
  • It will ask you if you would like to set up a Postgresql database and deploy now, hit No for both
  • If you do another ls -al,  you should now see a fly.toml file in your home directory. Open it in your editor, and make sure it looks like the following, paying special attention to everything before the [[services]] block:
# fly.toml file generated for mykuma

app = "mykuma"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  image = "louislam/uptime-kuma:latest"

[mounts]
source="kuma"
destination="/app/data"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"
note that the app name will be what you gave it in a previous step
  • Save the above, then run flyctl launch. After a lot of output, you'll see an error Mounts source volume "kuma" does not exist. No problem, simply run flyctl volumes create kuma, choose your region again, and it will create it for you
  • Now run flyctl deploy and your container will be spun up

Remember how I mentioned you'd be given an URL to access your Uptime Kuma instance? Typing in flyctl status will return a couple lines of information, one of which will be Hostname. Type this into your browser, and you'll find yourself directed to the Uptime Kuma welcome page where you can create your credentials.


Final thoughts

Security

The first thing I would do is create your login credentials and then enable 2FA in the settings. You don't own this server, and so you want to make your service on it as secure as possible.

Set up your monitors and notification service

Next, play around with the Uptime Kuma service, set up your monitors and your notification method (I use Pushover).

Access

Note that Fly.io could change their business model or availability whenever they want. Some people might be tempted to put more sensitive information or services on their servers (for instance Vaultwarden) and if that sounds good to you, be aware that you could lose that access at any time.

Monitoring the monitor

By signing into your account's dashboard at https://fly.io, you can check out how your instance is behaving and its resource usage. It's worth noting you only get 256MB RAM and a single shared CPU core, however I've had around 20 monitors running in Uptime Kuma and RAM hasn't gone over 200MB.

Updating Uptime Kuma

Whenever a new image is available, this is as simple as typing flyctl deploy again into your terminal. How you track a newly available image though is up to you...


Free selfhosted lab monitoring with Google Cloud Platform
A way to self-host a docker container which monitors the status of your (or any other) services. A free setup, this uses Google Cloud Platform

PTS

With very limited knowledge, PTS fell down the selfhosted rabbit hole after buying his first NAS in October 2020. You can find him on the Synology discord server (click the icon below)

Have some feedback or something to add? Comments are welcome!

Please note comments should be respectful, and may be moderated