Docker series builds a real-time health monitoring and alarm system for applications based on uptime and bark
This article was last updated 91 days ago. The information in it may have developed or changed. If it is invalid, please leave a message in the comment section.

Preface

As our internal applications become more and more numerous and complex, a problem that must be solved is how to monitor the health of all applications in real time and receive alerts as soon as problems occur. To solve this problem, we need to build our own real-time health monitoring and alert system for applications, which requires the cooperation of two applications: uptime-kuma and bark-server.

Deploy uptime-kuma

First, deploy uptime-kuma through docker. The command is as follows:

docker run --name uptime-kuma -d --restart=always \ -p 3001:3001 \ -v /docker/uptime-kuma/data:/app/data \ louislam/uptime-kuma 

Parameter explanation:
-p 3001:3001
This port is the host port mapped to the specified container. You can modify it according to your actual situation.
-v /docker/uptime-kuma/data:/app/data
It maps the host's /docker/uptime-kuma/data directory to the /app/data directory inside the container. All application health monitoring configurations configured on uptime-kuma are in this directory. If you need to migrate the container in the future, you only need to copy this directory and the configured data will not be lost.

Confirm container status

After the container is built, you can use Portainer to check whether it is successfully built, or you can use the following command to check:

docker ps -f name=uptime-kuma

If the status shows up and healthy, it means it is successfully established and running, as shown below:

image.png

Initialize uptime-kuma

After successfully establishing docker, use the browser to access it through http://host IP:3001. The first login will require you to create an administrator username and password. After the creation is completed, log in and enter. The default page is English. You can select "Simplified Chinese" in the drop-down menu in the upper right corner, select Settings-Appearance-Language, as shown below:

image.png

image.png

After changing the language, the entire interface becomes Chinese, as shown below:
image.png

The content in the red box on the left side of the above picture is the monitoring items that have been added, and the content on the right side is the setting items.

Add monitoring items

We add a newwww.example.comWe will take domain name monitoring as an example to demonstrate how to add monitoring items.

First, click the Add Monitoring Item button in the upper left corner of the above picture, and the following interface appears:

image.png

In the above picture, you only need to fill in the "Display Name" and "URL", and keep the default values for other settings. Finally, click the green button below to save:
image.png

Key settings

Monitoring Type:

Uptime-kuma supports multiple monitoring types, as shown below:

image.png

The default is the regular HTTP(S) type, and HTTP(S) also has two other types: keyword and JSON query. The keyword method can determine whether the application is normal based on whether specific characters exist in the response page. There are many other types to choose from, and friends who need this can study it by themselves.

Valid status codes:

The conventional HTTP(S) type simply determines whether the site is normal by the site response code. The default valid website response code is 200-299, which can be modified as needed.

notify:

When uptime detects a site status change, how to notify the administrator? I will share this in another article (see:Docker series builds a message push server based on bark server ) has been introduced in detail, so I will not elaborate on it here.

acting:

If the website to be monitored needs to be accessed through a proxy server, configure it here

HTTP options:

The default method is GET, and other methods can be selected

image.png

verify:

If the monitored web page requires authentication and the ability to log in is also used as a basis for judging whether it is healthy, you need to set it here:

image.png

The most commonly used method is actually the conventional HTTP(S) method. If you don’t have any special requirements, you can basically use the default configuration.

In fact, to achieve the real-time alarm function, the key is to choose the notification method. I personally recommend the bark method. You can install the app on your mobile phone (ios, android) and pad (pados, android), which is very convenient. The only trouble is that you need a public IP to build the bark-server. If your home broadband does not have a public IP, it is recommended to buy a cheap cloud host. For the specific bark-server construction method, see:Docker series builds a message push server based on bark server

Configuring public network access

If you want to publish to the public Internet, you need to choose the most suitable publishing method according to the actual environment and the reverse proxy you use. You can refer to my previous articles:
1,Docker series uses Docker to build its own reverse proxy based on NPM
2,Linux panel series configure reverse proxy and use non-443 port for publishing
3.Home data center series uses domestic cloud hosting to get free cloudflare to achieve fast access to domestic sites from abroad
4.Home Data Center Series: Use cloudflare to build a website quickly with no public IP in your home broadband (general purpose)

The first and second methods are suitable for environments with public IP but no legal 443 port (home broadband, unregistered cloud host). You need to add a non-standard port after the URL (if you use cloudflare to build a website, you don't need to add a port, but you need to customize the source station port. You can refer to:Home data center series uses cloudflare's Origin Rules to solve the problem of having a public IP but no legal ports 80 and 443 when building a websiteThe third method is suitable for cloud hosts with a record, and the fourth method is suitable for all environments (including environments without public IP), which is also the method I recommend (regardless of whether your environment has a public IP or not, because this method does not require running https traffic directly on the public network).

The content of the blog is original. Please indicate the source when reprinting! For more blog articles, you can go toSitemapUnderstand. The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if necessary, you can joinTelegram GroupDiscuss the problem together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠(ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ°Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Emoticons
Emoji
Little Dinosaur
flower!
Previous
Next
       

This site has disabled the right mouse button and various shortcut keys. The code block content can be copied directly by clicking the copy button in the upper right corner

en_US
春节
快乐