Using Netdata to Monitor Nginx

In this tutorial, How to Monitor the Nginx using Netdata on Centos 7. Netdata is a free open source. It is very easy to install and configure for real-time monitoring.

Steps install and configure

  • Centos 7 Server or RHEL 7 Server
  • Install Web Server Nginx
  • Install Netdata and configure Monitor for Web Server Nginx.

1. Install Web Server Nginx

Enable EPEL repository

[root@DevopsRoles ~]# yum install epel-release

Install the Nginx package, as follows.

[root@DevopsRoles ~]# yum install nginx

Start and enable Nginx Web Server, as follows.

[root@DevopsRoles ~]# systemctl start nginx
[root@DevopsRoles ~]# systemctl enable nginx
[root@DevopsRoles ~]# systemctl status nginx

If you are running a firewall. You need to open port 80/443 for Nginx Webserver.

Enable Nginx Stub_Status Module

I will enable the stub_status module which netdata uses to collect metrics from your Nginx web server.

[root@DevopsRoles ~]# vi /etc/nginx/nginx.conf

Copy and paste the location configuration as below

location /server_status {
 	stub_status;
 	allow 127.0.0.1;	#only allow requests from localhost
 	deny all;		#deny all other hosts	
 }

restart the Nginx service to effect

[root@DevopsRoles ~]# nginx -t
[root@DevopsRoles ~]# systemctl restart nginx

Now, Use curl command to check

curl http://127.0.0.1/server_status

# The output terminal as below:
[root@DevopsRoles ~]# curl http://127.0.0.1/server_status
Active connections: 1 
server accepts handled requests
 1 1 1 
Reading: 0 Writing: 1 Waiting: 0

3. Install Netdata on Centos 7 here

4. Configure Netdata to Monitor Nginx

The Netdata configure for Nginx in folder /etc/netdata/python.d which is written in YAML format.

You can open it or create a new file nginx.conf as below

[root@DevopsRoles python.d]# cat /etc/netdata/python.d/nginx.conf 
# The output as below:
localhost:
  name : 'local'
  url  : 'http://localhost/server_status'

localipv4:
  name : 'local'
  url  : 'http://127.0.0.1/server_status'

Restart Netdata Server

[root@DevopsRoles ~]# systemctl restart netdata 

5. Using Netdata to Monitor Nginx Web Server

Open a web browser access the netdata web UI.

http://NETDATA_SERVER_IP:19999
or
http://DOMAIN_NAME:19999

The result as the picture below

Netdata to Monitor Nginx

Conclusion

Through the article, you can use Netdata to monitor Nginx. I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.