Step-by-step Guide to Monitoring Debian Server with Netdata
13:46, 10.06.2024
Monitoring your server is one of the essential practices that can help you regularly take measures to improve the performance of your website, reveal its weak spots to enhance its security, and figure out, how to increase the number of its visitors, achieve better SEO optimization, etc.
Nextdata is a tool that can help you with tasks of this kind in a variety of regards, allowing you to collect data in real-time and regardless of what kind of network infrastructure you have — be it a VPS or a dedicated server.
Let’s have a look at this tool and how to use it to monitor a Debian server.
Exploring Netdata's Features
Netdata is an open-source, real-time performance and health monitoring tool for systems and applications, with which you can visualize and troubleshoot a system's performance in real time. The key features of Netdata include:
Real-time monitoring
With Netdata you can get real-time insights into a wide variety of metrics, such as CPU usage, memory consumption, disk I/O, network traffic, and many more. The information is updated every second, so you can check any time what’s going on with your system.
No need for configuration
Once you install Netdata, there is no more need for additional configuration. As soon as it’s installed, it will automatically start to monitor diverse system metrics, as well as apps and services without you making any extra actions.
Web-based dashboard
On Netdata you can use an interactive, web-based dashboard with a detailed and comprehensive view of your system's performance. The dashboard has vast customizability options, so you can get whatever you want regardless of your idea about it.
Extensive metrics collection
Collect thousands of metrics from a variety of resources, including the OS, applications, as well as third-party services to monitor your projects from every corner.
Alerting and notifications
Apart from real-time monitoring, Netdata also supports alerting features. This way, for instance, you can configure alerts for specific metrics so you receive notifications as soon as a certain threshold is exceeded, so you are always ready to address critical issues.
Lightweight and efficient
Although the Netdata tool is really massive in terms of its functionality, it is also designed to be lightweight yet efficient. Since its resource requirements are as minimal as possible, you can run it even on the most basic VPS.
Open-source and community-driven
Netdata is an open-source solution, so it’s driven by a vast community of users who are free to make their own modifications to the program.
Cross-platform support
Netdata can run on various widely used operations systems, including most Linus distributions, macOS, as well as FreeBSD. Its monitoring capabilities can extend to Docker containers Kubernetes clusters and many other environments, so it can be regarded as truly versatile.
Stage 1: Dependency Installation
Now, let’s move on to the installation process of Netdata.
Before moving on to the installation of Netdata, make sure to install the necessary dependencies:
sudo apt update && sudo apt upgrade -y
sudo apt install dirmngr gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm libassuan0 libksba8 libnpth0 pinentry-curses
Stage 2: Netdata Installation
A recommended method of installing Netdata is by using the kickstart.sh script. Run this command and select YES each time:
wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --stable-channel
–stable-channel in the command signifies the installation of the stable version.
After the successful installation, you’ll see an output starting with “Successfully installed the Netdata Agent”.
The status can be checked with the command:
$ systemctl status netdata
Now you can access Netdata through your browser with the command:
http://<your-ip-address>:19999
Stage 3: Configure Netdata
Once installed, Netdata will start listening on every interface on your server which means maximum potential attack surface. To minimize the attack surface and this way increase the security of the whole server, it’s recommended to configure Netdata to listen only on localhost.
Do it by opening the file as shown and adding the lines under [global]
$ sudo vim /etc/netdata/netdata.conf
[global]
run as user = netdata
# default storage size - increase for longer data retention
page cache size = 32
dbengine multihost disk space = 256
bind to = 127.0.0.1
For this take effect, restart Netdata:
–stable-channel in the command signifies about the installation of the stable version.
After the successful installation, you’ll see an output starting with “Successfully installed the Netdata Agent”.
The status can be checked with the command:
$ systemctl status netdata
Now you can access Netdata through your browser with the command:
http://<your-ip-address>:19999
1. Installing Nginx
To secure and manage access more effectively, you should set up Nginx to serve as a reverse proxy:
$ sudo apt install nginx
After the successful installation, create a configuration file for Netdata in Nginx:
$ sudo nano /etc/nginx/sites-available/netdata
Add the following configuration, adjusting server_name to your domain or IP address:
server {
listen 80;
server_name your_server_ip;
location / {
proxy_pass http://localhost:19999;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Enable the configuration by creating a symlink:
$ sudo ln -s /etc/nginx/sites-available/netdata /etc/nginx/sites-enabled/
Finally, check for syntax errors and restart Nginx:
$ sudo nginx -t
$ sudo systemctl restart nginx
2. Password Authentication
For now Netdata is open and can be accessed by any users. To allow only authorized users to view the server information through Netdata, you should set up password authentication. Install Apache2 utilities and create a .htpassword file, which will store the username and password.
$ sudo apt-get install apache2-utils
Create the file and add the username replacing username with your preferred username:
$ sudo htpasswd -c /etc/nginx/.htpasswd username
Update the Nginx configuration for Netdata to include password authentication:
$ sudo nano /etc/nginx/sites-available/netdata
Add the following lines inside the location / block:
auth_basic "Protected";
auth_basic_user_file /etc/nginx/.htpasswd;
Check if everything is typed correctly and restart Nginx once more:
$ sudo nginx -t
$ sudo systemctl restart nginx
Wrapping Up
This has been a brief guide on how to start using Netdata to monitor your Debian server. This is a highly versatile tool that will allow you to monitor metrics on the various aspects of your server's performance. As you have seen, it doesn’t require a long initial setup, so if you followed the instructions provided, you should by now be able to utilize Netdata as you see fit. Good luck!