Open Source Lightweight Server Monitoring Tool Beszel: Installation and Usage Guide Based on Docker

Publish: 2024-10-12 | Modify: 2024-10-12

Beszel is an open-source lightweight server resource monitoring tool that supports real-time monitoring of key server resources and records historical data. It presents critical metrics such as CPU, memory, and disk I/O through an intuitive interface, and also supports monitoring the operational status of Docker containers, helping users better understand container performance. Additionally, Beszel features an alert system that promptly notifies administrators of any anomalies, ensuring stable system operation. With a straightforward installation and configuration process, Beszel is well-suited for the daily monitoring needs of small and medium-sized servers.

3d198574915e7ce3.png

Features of Beszel

  • Lightweight: Smaller and consumes fewer resources than mainstream solutions.
  • Simple: Easy to set up, no exposure to the public internet required.
  • Docker Statistics: Tracks CPU, memory, and network usage history for each container.
  • Alerts: Configurable alert features for CPU, memory, disk usage, and system status.
  • Multi-user: Each user manages their own systems, and administrators can share systems with others.
  • OAuth / OIDC: Supports various OAuth2 providers, allowing password authentication to be disabled.
  • Automatic Backup: Data can be saved to disk or an S3-compatible storage, with support for recovery.
  • REST API: Data can be used or updated in your scripts and applications.

Architecture of Beszel

The architecture of Beszel is a monitoring platform based on a client-server model, consisting of a Hub (central server) and Agent (proxy).

Hub (Central Server)

  • Function: The Hub serves as the central server for Beszel, aggregating and displaying monitoring data. It receives data from multiple systems and displays server resource usage, such as CPU, memory, and disk I/O historical data.
  • Deployment: Can run through a single binary file or Docker container. The Hub does not need to be exposed to the public internet, enhancing security.

Agent (Proxy)

  • Function: The Agent is a lightweight program installed on the monitored system. It collects server resource usage data and sends it to the Hub. The Agent also supports monitoring Docker containers, tracking their CPU, memory, and network usage.
  • Deployment: The Agent can be installed using a Docker container or a single binary file, supporting multiple file systems and network interfaces through simple environment variable configuration.

Deploying Beszel with Docker

In this article, Xiaoz demonstrates how to deploy Beszel using Docker Compose, assuming you have Docker installed.

Deploying Beszel Hub

The Hub can be understood as the backend of Beszel, responsible for display/management and alerting. At least one server is required to use Beszel. Next, we will deploy the Beszel Hub using Docker Compose, with the detailed docker-compose.yaml content as follows:

services:
  beszel:
    image: 'henrygd/beszel'
    container_name: 'beszel'
    restart: unless-stopped
    ports:
      - '8090:8090'
    volumes:
      - ./beszel_data:/beszel_data

Then, use docker-compose up -d to start it. After successful startup, access the WEB page via http://IP:8090 and set an admin email and password for future use.

6c1486101b5084e4.png

Deploying Beszel Agent

The Agent acts as the client for Beszel, responsible for collecting data and reporting it to the Hub (server). We need to install the Agent on each server to monitor all servers. It is also deployed via Docker Compose, first needing to click Add System in the Beszel backend - top right.

eac6a04be861673e.png

Then fill in the server IP/port information and click the Copy docker compose button.

c9c802a1c9d5fe79.png

This will automatically generate the docker-compose.yaml content in the following format:

services:
  beszel-agent:
    image: "henrygd/beszel-agent"
    container_name: "beszel-agent"
    restart: unless-stopped
    network_mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # monitor other disks / partitions by mounting a folder in /extra-filesystems
      # - /mnt/disk1/.beszel:/extra-filesystems/disk1:ro
    environment:
      PORT: 45876
      KEY: "ssh-ed25519 xxx"
      # FILESYSTEM: /dev/sda1 # override the root partition / device for disk I/O stats
  • Note: Please change KEY to your own.

Save the above content as docker-compose.yaml and enter the command docker-compose up -d to start the Beszel Agent. The above yaml configuration shows that the HOST network mode is used, with 45876 as the port, so we also need to allow port 45876 in the firewall or security group for communication. The method is as follows:

# If using firewalld
firewall-cmd --zone=public --add-port=45876/tcp --permanent
firewall-cmd --reload
# If using ufw
ufw allow 45876

After completing these operations, don't forget to return to the Beszel page and click the Add System button.

875dbcd799b2f7f4.png

Then wait a few minutes, and you will see monitoring data on the page.

3bd0148f9899dde1.png

Another benefit of Beszel is its ability to monitor Docker container resources, which is quite impressive.

1cb0b30884ed52b6.png

Other Features

Beszel also allows you to set a dark mode.

0cbf25e5ab12c9ae.png

You can also configure SMTP to send emails.

d517660674a67de5.png

It can also monitor and alert on server metrics.

e09f1d411951d555.png

You can back up files to S3-compatible object storage. (Xiaoz is not sure whether this part is for log files or something else)

1b8b491857e1d53c.png

Additionally, Beszel supports API and Webhook functionalities, greatly facilitating operations and development. Interested friends can further explore.

Discussion of the Advantages and Disadvantages of Beszel

The following are Xiaoz's personal opinions for reference only.

Advantages of Beszel

  • Relatively simple installation
  • Lightweight and concise, meeting basic monitoring needs
  • Supports Docker container resource monitoring

Disadvantages of Beszel

  • The interface does not support Chinese
  • Once a server is added, it cannot be modified; modifications seem to require deletion and re-adding
  • Not user-friendly for servers with multiple disks
  • Monitoring metrics are not detailed enough, such as the inability to monitor server network connection counts

Comparison with Prometheus

Currently, Xiaoz uses the Prometheus + Grafana monitoring solution for most servers; this monitoring solution is very mature and aesthetically pleasing. Recently, after discovering Beszel, a deployment test was conducted. Each has its strengths and weaknesses; if it's for a company's production environment, I still recommend mature solutions like Prometheus or Zabbix. If it's your own server and you don't mind more detailed metrics, Beszel can fully meet the needs. Below is a personal non-professional comparison for reference.

Name/Function Beszel Prometheus
Installation Simple Difficult
Usage Simple Difficult
Monitoring Docker Containers Default Support Requires Extra Configuration
Alerts Default Support Requires Extra Configuration
Monitoring Metrics General Rich
Monitoring Multiple Disks General User-friendly
Auto Discovery Not Supported Supported

Note: Beszel has very friendly support for Docker, so you can also install Beszel on your NAS device!

Conclusion

Beszel is an open-source tool designed for lightweight server monitoring, capable of meeting the daily monitoring needs of small and medium-sized servers through simple configuration. In a Docker environment, the deployment of Beszel is particularly convenient, supporting resource monitoring of Docker containers. Additionally, it includes alerting, data backup, and API integration features to help users respond quickly in the event of an anomaly. Although it may not compare to mature solutions like Prometheus in some advanced monitoring features, for personal servers or small projects that do not require complex configurations, Beszel remains an excellent choice.

Beszel project address: https://github.com/henrygd/beszel


Comments