Uptime Kuma on Amazon EC2 (Ubuntu) - An Open-source Monitoring Tool
Tags: monitoring, aws, opensource
Published: 2023-05-03 15:01:07

> 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

```bash
$ ssh -i uptime-kuma.pem ubuntu@54.234.8.87
```

Create a Docker volume for Uptime Kuma

```bash
$ docker volume create uptime-kuma

$ docker volume ls
DRIVER    VOLUME NAME
local     uptime-kuma
```

Start the container and verify the status

```bash
$ 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
```

```bash
$ 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
```

Open [http://54.234.8.87:3001](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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bza50a9q2qyaiwx3n4t1.png)

Once done, we will redirect to the dashboard

![uptimekuma-02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkfbowrf1lbval1syhk8.png)

## Configuration

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

![uptimekuma-03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/idy66jr9iy30765rjuav.png)

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 **Settings** → **Notifications** → **Setup Notification** and configure as below to receive email notifications

**Notification Type**: Email (SMTP)
**Friendly Name**: Alerts
**Hostname**: [smtp.gmail.com](http://smtp.gmail.com)
**Port**: 587
**Security:** None/STARTTLS (25, 587)
    
![uptimekuma-04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rk59oh70zga83fcmo2cr.png)
    
**Username**: &lt;your-email-id&gt;
**Password**: &lt;app-password&gt;
**From Email**: &lt;your-email-id&gt;
**To Email**: &lt;your-email-id&gt;
    
![uptimekuma-05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8v2pr5omx5verbxfgwcl.png)
    
**Custom Subject**: `{{NAME}} {{STATUS}}`
**Default enabled**: Enable
    
![uptimekuma-06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6xz87fsbfvj1y2in3vr.png)

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

![uptimekuma-07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qt0w4mmz90xow2137fj2.png)

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](http://158b5452c43c.mylabserver.com)
**URL**: [https://158b5452c43c.mylabserver.com]  (https://158b5452c43c.mylabserver.com)
**Heartbeat Interval**: 20
**Certificate Expiry Notification**: Enable
    
![uptimekuma-08](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e0v8gw89pamxfnqoydmd.png)

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

![uptimekuma-09](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpkyogg6ksutej4pj4bx.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2la3izfn9nm8wwf6cfbw.png)

![uptimekuma-11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40yr2f4vyknn9n1cxnnv.png)

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

![uptimekuma-12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qrrjp5eg0bgc14tdqizt.png)

![uptimekuma-13](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwi7tvfoec7bc74ab0rn.png)

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 **Settings** → **Notifications** → **TLS 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/unptihfn8afgd31igee4.png)

![uptimekuma-15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du2cbj2ntz2k08ana4f6.png)

## Reference

[https://github.com/louislam/uptime-kuma](https://github.com/louislam/uptime-kuma)

[https://mariushosting.com/synology-activate-gmail-smtp-for-docker-containers/](https://mariushosting.com/synology-activate-gmail-smtp-for-docker-containers/)