Learn how to achieve easy off-site monitoring thanks to fly.io and Uptime Kuma.
When setting up monitoring for one's infrastructure it is a good idea to do this on a server that is independent from the current infrastructure (other region, hosting provider, ...). After all: How is your monitoring supposed to notify you, if it is hit by the same downtime as your other services? But what if you only have a hand full of machines and don't want to spend extra just for reliable monitoring?
Luckily there are some hosting companies who offer "free tiers" of their service (usually with quite restricted resources) that can be utilised to host a low resource monitoring system such as Uptime Kuma. The hosting provider of my choice for this is fly.io since, they have a little command line utility which allows me to directly launch a Docker container on their infrastructure, while they take care of persistent storage and Let's Encrypt secured web access. All of this for free and in one of 22 regions.
All we need to do after downloading their utility and creating an account is creating the following file on our local system and adjust a few values in it.
The value of
app needs to be unique and is basically the subdomain Uptime Kuma will be operating from, therefore this needs to be a unique name. In the above example the address for Uptime Kuma would be
https://mykuma.fly.dev. But don't worry you don't need to use the
fly.dev domain name and can later easily add your own domain to the system.
# fly.toml file generated for mykuma app = "mykuma" kill_signal = "SIGINT" kill_timeout = 5 processes =  [build] image = "louislam/uptime-kuma:1.17.1" [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"
Now we first need to run
flyctl launch to initialize the app, followed by
flyctl volumes create kuma to create the persistent storage and then we can run
flyctl deploy which will download the image specified in
build.image and start it on the fly.io infrastructure. This is the point in time where we are leaving the command line and instead use our preferred browser to perform the initial setup for Uptime Kuma.
Using your own domain for the Uptime Kuma dashboard and status pages
The way Uptime Kuma is designed you have your own private monitoring dashboard (where you can create additional monitors and see the detailed status) at one domain (mykuma.fly.dev in the above example) and then can have a public "Status Page" on a completely separate domain. To tell fly.io that is should respond to our own domain, we need to create a "certificate" for. This can be done through the fly.io dashboard or through
flyctl. For my own setup I created a `CNAME` entry in the Cloudflare UI pointing to the "Hostname" fly.io gave for my deployed app and then executed the below command to register this domain entry with fly.io:
flyctl certs create status.mydomain.com
Once the domain is registered I can create a "New Status Page" within Uptime Kuma and assign `status.mydomain.com` in its settings as the "Domain Name[s]".
Updating Uptime Kuma
Once the initial setup is completed updating is simply done through changing the
build.image in the configuration to the desired version and rerunning
How to get notified?
In terms of notifications the same principles apply and using your self hosted email or chat server should be avoided (at least for urgent notifications). Luckily Uptime Kuma supports a large list of providers to choose from. For my own I am simply sending notifications through Telegram.
You can also spin up an instance of Uptime Kuma with PikaPods with one click for as little as $1.4/mo! Get $5 credit free when you signup.