How to Monitor Nginx using Netdata on CentOS 7

Prerequisites

  1. You must have an Alibaba Cloud Elastic Compute Service (ECS) instance activated and have verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  2. A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.

Install Nginx Web server

Before installing netdata on your CentOS server, we will have to install nginx web server. Nginx web server can be installed from epel repository. so first install EPEL repository using following command, if you do not have it.

yum -y install epel-release
yum -y install nginx
systemctl start nginx
systemctl enable nginx
firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanent
firewall-cmd --reload
yum -y install firewalld

Enable Nginx Module

To install netdata you’ll have to enable ‘stub_status’ module and you can do that by editing the configuration file ‘nginx.conf’. Go to the ‘/etc/nginx/’ directory using following command.

cd /etc/nginx/
nano nginx.conf
yum -y install nano
location /stub_status {  
stub_status;
# Security: Only allow access from the IP below.
allow 127.0.0.1;
# Deny anyone else
deny all;
}
nginx -t
systemctl restart nginx

Install Netdata

Now we will install netdata to monitor nginx server. You’ll need to install some required packages before installing netdata and you can do so using following command.

yum -y install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig curl jq nodejs
cd ~
git clone https://github.com/firehol/netdata.git --depth=1
cd netdata/
sudo ./netdata-installer.sh
sudo firewall-cmd --permanent --add-port=19999/tcp
sudo firewall-cmd --reload
systemctl restart netdata
systemctl enable netdata
netstat -plntu

Monitor Nginx using Netdata

All the required packages have been installed and now we are ready to monitor our nginx server using netdata. To monitor system applications netdata provides modules. There are some applications like Apache, Nginx, MongoDB etc that use python modules for monitoring using Netdata.

cd /etc/netdata/python.d/
nginx.conf
localhost:  
name : 'local'
url : 'http://localhost/stub_status'
systemctl restart netdata

Testing

Netdata is successfully installed and running on your server. Open your favorite web browser to test it. Point your web browser to YourServerIP with port 19999.

http://YourServerIPAddress:19999

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com