There are tons of monitoring tools that are used for keeping an eye on systems performance and sending notification in case something goes incorrect. However, the installation and configuration steps included are often tedious.
An open-source real-time monitoring & troubleshooting tool is Netdata which only wants a few steps to get installed. The Git repository comes with an automated script that manages the bulk of the installation and configuration process and takes away the cumbersome configuration associated with other monitoring tools.
Netdata has become hugely popular since its initial release in October 2013. It collects real-time metrics such as CPU and RAM usage, bandwidth statistics, and disk utilization and presents them on easy-to-interpret charts/graphs.
It has made giant leaps and bounds, and this has gained it a place in Forbes 2020 Cloud 100 rising stars. This list constitutes the top 100 private cloud companies.
In this article, you will see how can install Netdata on CentOS 8/7 to manage real-time, performance, and health monitoring of servers and applications.
Supported Platforms
Netdata supports the following distributions:
- CentOS 8 and CentOS 7
- RHEL 8 and RHEL 7
- Fedora Linux
How to Install Netdata in CentOS Linux
1. Before you jump into the installation of Netdata, a few essential packages are compulsory. But first, update the system and install the EPEL repository as shown.
$ sudo yum update
$ sudo yum install epel-release
2. Next, install the requisite software packages as shown.
$ sudo yum install gcc make git curl zlib-devel git automake libuuid-devel libmnl autoconf pkgconfig findutils
3. Once you are through with installing the required packages, clone the Netdata git repository as shown.
$ git clone https://github.com/netdata/netdata.git --depth=100
4. Next, navigate into the Netdata directory and perform the install-required-packages.sh script. The script identifies your Linux distribution and installs additional packages that are required during the installation of Netdata.
$ cd netdata/
$ ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
5. Finally, to install Netdata, run the Netdata automated script as shown below.
$ sudo ./netdata-installer.sh
In execution of the script, you will be briefed on where crucial Netdata files will be stored. These involve such as configuration files, web files, plugins, database files and log files to mention just a few.
6. Press ‘ENTER‘ to get started with the installation process. During the installation process, you will be given some tips on how to access Netdata on the browser and control the Netdata such as starting and stopping it.
The script works for quite a while performing all the required configurations and tweaks during the installation process. For my case, it took about 3-5 minutes, and once done, the output displayed should be a confirmation that the installation was successful.
7. Once installed, we require to have the Netdata daemon up and running. To start, enable the Netdata daemon on boot, and check the status invoke the following commands:
$ sudo systemctl start netdata
$ sudo systemctl enable netdata
$ sudo systemctl status netdata
8. By default, Netdata listens on port 19999, and you can confirm this using the netstat command as shown:
$ sudo netstat -pnltu | grep netdata
9. You require to open this port on the firewall to have access to Netdata via a browser. Therefore run the commands below:
$ sudo firewall-cmd --add-port=19999/tcp --permanent
$ sudo firewall-cmd --reload
10. To access Netdata, fire up your browser, and browse the URL as shown:
$ http://centos8-ip:19999/
You will get a dashboard displayed, giving you the overall system performance on intuitive and cool graphs.
Feel free to have a look at different graphs by clicking on the metrics listed on the right sidebar. For example, to have a glimpse of the systemd services running, click on the ‘systemd services’ option as shown.
Securing Netdata with Basic Authentication on CentOS
As you might alarmingly have observed, there’s no form of authentication given by Netdata. This implies that virtually anyone can access the dashboard provided they get a hold of Netdata’s IP address.
Thankfully, we can configure necessary authentication using the htpasswd program and the Nginx web server as the reverse proxy. Therefore, we are moving to install the Nginx web server.
$ sudo dnf install nginx
With Nginx installed, we are going to create a configuration file inside the /etc/nginx/conf.d directory. However, feel free to use the sites-available directory if you are using Nginx for other goals aside from Netdata.
$ sudo vim /etc/nginx/conf.d/default.conf
Add the following entire configuration and make sure to adjust the server_ip and example.com directives with your server IP address and server name.
upstream netdata-backend {
server 127.0.0.1:19999;
keepalive 64;
}
server {
listen server_ip:80;
server_name example.com;
auth_basic "Authentication Required";
auth_basic_user_file netdata-access;
location / {
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;
proxy_pass http://netdata-backend;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
}
}
For user authentication, we will generate a username and password for a user ,using the htpasswd tool and save the credentials under the netdata-access file.
$ sudo htpasswd -c /etc/nginx/netdata-access
Next, restart the Nginx web server for the changes to come into effect.
$ sudo systemctl restart nginx
o test if the configuration went right, proceed and browse your server’s IP address.
http://server-ip
Thereafter, you will get access to the Netdata dashboard.
And that’s it, folks. We have walked you through the installation of the Netdata Monitoring tool on CentOS 8 and configured basic authentication to secure the monitoring tool.