Netdata is an open source monitoring system for Linux servers. It provides real-time performance and health monitoring with beautiful dashboard and analytics. Netdata should run on any Linux distribution - has been tested on Alpine Linux, Arch Linux, CentOS, Ubuntu etc. It offers real-time health monitoring tools for your servers, CPU, memory usage, IPv4 and IPv6 networks and user applications such as Nginx, fail2ban, MySQL, MongoDB etc.
In this tutorial, I will show you how to monitor Nginx using Netdata. This tutorial will cover the Nginx web server installation, enabling of the 'stub_status' module, and Netdata installation on CentOS 7.
What we will do
Install Nginx Webserver.
Enable Nginx 'stub_status' module.
Install Netdata on CentOS 7.
Monitor Nginx using Netdata.
Testing.
Prerequisites
CentOS 7 Server
Root privileges
Step 1 - Install Nginx Web server
In this step, we will install the Nginx web server from the EPEL (Extra Packages for Enterprise Linux) repository. Before installing Nginx, make sure the EPEL repository has been installed on your server.
If you do not have it, you can install it using the command below.
yum -y install epel-release
Next, install Nginx with the yum command below.
yum -y install nginx
And if the installation has been completed, start the service and enable it to launch automatically at system boot using the systemctl commands below.
systemctl start nginx
systemctl enable nginx
After the installation, open HTTP and HTTPS ports using the firewall-cmd command below.
firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanent
firewall-cmd --reload
Note: If you do not have the firewall-cmd command, you can install the firewalld packages from the repository.
yum -y install firewalld
The Nginx web server has been installed.
Step 2 - Enable Nginx stub_status module
To monitor Nginx using Netdata, we must enable the 'stub_status' module by editing the configuration. Make sure your Nginx version has a module named 'stub_status', check the module with the command below.
nginx -V
You should get a result similar to the following.
Make sure you have the 'stub_status' module on the list.
Next, edit the nginx configuration file 'nginx.conf' to enable the 'stub_status' module. Go to the '/etc/nginx/' directory and edit the configuration with vim.
cd /etc/nginx/
vim nginx.conf
Paste the following configuration inside the 'server {}' block.
location /stub_status { stub_status; # Security: Only allow access from the IP below. allow 127.0.0.1; # Deny anyone else deny all; }
Save and exit.
Now, test the nginx configuration and make sure there is no error. Then restart nginx.
nginx -t
systemctl restart nginx
Nginx 'stub_status' module has been enabled - we can check it using the curl command as shown below.
curl http://127.0.0.1/stub_status
When it's enabled, you can see the result as below.
Step 3 - Install Netdata on CentOS 7
In this step, we will install Netdata on the CentOS 7 server. Before installing Netdata, we need to install some packages for Netdata installation.
Install packages needed for Netdata installation using the following yum command.
yum -y install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig curl jq nodejs
Next, download Netdata source code using the following git command.
cd ~
git clone https://github.com/firehol/netdata.git --depth=1
Go to the netdata directory and run the Netdata installer script with sudo privileges.
cd netdata/
sudo ./netdata-installer.sh
Press 'Enter' to continue with the Nedata installation.
And when the installation is complete, you will see the result as below.
Netdata has been installation on CentOS 7, and it's running on port '19999'.
Open the port using the firewall-cmd command below.
sudo firewall-cmd --permanent --add-port=19999/tcp
sudo firewall-cmd --reload
Netdata provides a systemd services script, so you can manage Netdata using the systemctl command. Restart netdata and enable it to launch automatically every time at system boot.
systemctl restart netdata
systemctl enable netdata
Check the opened port of the server - make sure you get the port 19999 on the 'LISTEN' state.
netstat -plntu
The Netdata monitoring tool has been installed on CentOS 7.
Step 4 - Monitor Nginx using Netdata
At this stage, Nginx has been installed, the stub_status module has been enabled, and the Netdata installation has been completed. In this step, we want to monitor the nginx web server using Netdata. Monitoring for requests, active connection, and the status.
Netdata provides modules for monitoring system applications. There are some applications like Apache, Nginx, MongoDB etc that use python modules for monitoring using Netdata.
Go to the netdata 'python.d' directory and edit the configuration file nginx.conf using vim.
cd /etc/netdata/python.d/
vim nginx.conf
Go to the bottom line and make sure you have a configuration as shown below.
localhost: name : 'local' url : 'http://localhost/stub_status'
Save and exit.
Now restart the netdata service using the systemctl command.
systemctl restart netdata
Step 5 - Testing
Open your web browser and visit the server IP address with port 19999.
http://192.168.1.11:19999/
And you will get the Netdata Dashboard.
Click on the 'nginx local' on the right, and see Nginx active connections, requests, status and the connection rate.
Netdata has been installed on the CentOS 7 server, and the Nginx web server is being monitored using Netdata.
Preference
https://github.com/firehol/netdata/wiki/