DEV Community

Cover image for Uptime Kuma on Amazon EC2 (Ubuntu) - An Open-source Monitoring Tool
Unni P
Unni P

Posted on • Originally published at iamunnip.hashnode.dev

Uptime Kuma on Amazon EC2 (Ubuntu) - An Open-source Monitoring Tool

In this article, we will look at how we can install and configure Uptime Kuma an open-source monitoring tool on Amazon EC2 Ubuntu instance

Introduction

  • An open-source self-hosted monitoring tool

  • Monitor uptime for HTTP, HTTPS, DNS etc

  • SSL certificate information

  • Notifications via Email, Slack, Discord etc

  • 20 seconds interval

  • Support for proxy and multi-factor authentication

Prerequisites

  • Setup an EC2 instance of type t2.micro

  • Ubuntu 22.04 LTS as AMI

  • 10 GB of hard disk space

  • Open port 22 for SSH and 3001 for Uptime Kuma

  • Install and configure Docker

  • Need a temporary webpage with SSL enabled

Installation

Login to your EC2 instance

$ ssh -i uptime-kuma.pem ubuntu@54.234.8.87
Enter fullscreen mode Exit fullscreen mode

Create a Docker volume for Uptime Kuma

$ docker volume create uptime-kuma

$ docker volume ls
DRIVER    VOLUME NAME
local     uptime-kuma
Enter fullscreen mode Exit fullscreen mode

Start the container and verify the status

$ docker container run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
Unable to find image 'louislam/uptime-kuma:1' locally
1: Pulling from louislam/uptime-kuma
3689b8de819b: Pull complete
4178a276654a: Pull complete
b46162c13de5: Pull complete
4d3ac03f17d8: Pull complete
b935255dae7e: Pull complete
792f129a81f3: Pull complete
4110002867ba: Pull complete
390f8662c74f: Pull complete
9dd174cf6e30: Pull complete
4f4fb700ef54: Pull complete
703bad70ccf2: Pull complete
Digest: sha256:cf61d3262b29e1c48cc2ac284c9264227bbc46168f408e5f4c4d6301f0629e41
Status: Downloaded newer image for louislam/uptime-kuma:1
fcdfcc5a5d1470ca3b1dd1e23d29a4975d909e2a5ab2f53e1e2bef0fa4a58665
Enter fullscreen mode Exit fullscreen mode
$ docker container ls -a
CONTAINER ID   IMAGE                    COMMAND                  CREATED              STATUS                        PORTS                                       NAMES
fcdfcc5a5d14   louislam/uptime-kuma:1   "/usr/bin/dumb-init …"   About a minute ago   Up About a minute (healthy)   0.0.0.0:3001->3001/tcp, :::3001->3001/tcp   uptime-kuma
Enter fullscreen mode Exit fullscreen mode

Open http://54.234.8.87:3001 in your browser

Initially, we need to set up a username and password for accessing the dashboard

uptimekuma-01

Once done, we will redirect to the dashboard

uptimekuma-02

Configuration

I have already configured an Nginx website and enabled SSL using Let’s Encrypt

uptimekuma-03

We need to set up Notifications to get notified whenever a host is down or a certificate is going to expire

If we are using Email (SMTP) as a notification type then we need to do configuration in our Gmail account

  • Enable multi-factor authentication

  • Create app password

From the dashboard, navigate to SettingsNotificationsSetup Notification and configure as below to receive email notifications

Notification Type: Email (SMTP)
Friendly Name: Alerts
Hostname: smtp.gmail.com
Port: 587
Security: None/STARTTLS (25, 587)

uptimekuma-04

Username: <your-email-id>
Password: <app-password>
From Email: <your-email-id>
To Email: <your-email-id>

uptimekuma-05

Custom Subject: {{NAME}} {{STATUS}}
Default enabled: Enable

uptimekuma-06

Once the required information is entered click the Test and Save button and you will receive a test mail in your inbox

uptimekuma-07

Let's add our URL to monitor by clicking the Add New Monitor button and filling in the details and clicking the Save button

Friendly Name: 158b5452c43c.mylabserver.com
URL: https://158b5452c43c.mylabserver.com
Heartbeat Interval: 20
Certificate Expiry Notification: Enable

uptimekuma-08

From the dashboard, we can see the uptime, response time of our URL and certificate expiry date

uptimekuma-09

Now make a downtime by stopping the Nginx service and we can see our URL is showing the status as DOWN and will receive an email in your inbox

uptimekuma-10

uptimekuma-11

Let's start the Nginx service now our URL status is showing as UP and will receive an email in your inbox

uptimekuma-12

uptimekuma-13

As you see from the above status, the Let’s Encrypt certificate is going to expire in 89 days.

Let's configure Uptime Kuma to receive an alert for certificate expiry

Navigate to SettingsNotificationsTLS Certificate Expiry

**By default, we will get certificate expiry notifications in 7, 14 and 21 days but we are going configure it as 89 days because my certificate will expire in 89 days click the **Save
button and wait to receive an email in your inbox

uptimekuma-14

uptimekuma-15

Reference

https://github.com/louislam/uptime-kuma

https://mariushosting.com/synology-activate-gmail-smtp-for-docker-containers/

Top comments (0)