Serverspace Black Friday
WT
June 15, 2023
Updated June 14, 2023

Monitoring Nginx with Zabbix

Monitoring NGINX Zabbix

Nginx is a widely presented web server that is often employed to serve static content, reverse proxy, or load balance web traffic. It is well-known for its reliability, flexibility, and high performance. As with any server, it is important to monitor Nginx to ensure it is functioning appropriately and to address any issues that may arise. In this article, we will explore how to monitor Nginx with Zabbix, to proactively detect and resolve any problems with your Nginx server.

Preparations

Before we start exploring the process of monitoring Nginx with Zabbix, we need to ensure that we meet the prerequisites. These include:

Configuring Nginx

Open the /etc/nginx/conf.d/stub_status.conf file with the editor of your choice and paste the following text block:


server {
listen 127.0.0.1:80;
server_name 127.0.0.1;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location = /basic_status {
stub_status;
allow 127.0.0.1;
allow ::1;
deny all;
}
}

Config file
It makes the server generate basic status information on /basic_status page available only from this same server, so our agent can get it to the server.

Now lets check if Nginx procces is fine with new settings by running:

nginx -t

systemctl restart nginx

systemctl status nginx

nginx status

Next lets's see if the new status page works with curl:

curl http://127.0.0.1/basic_status

Status page

Configuring logs

You should check if Nginx generates the logs needed by Zabbix by checking logging settings in /etc/nginx/nginx.conf

Log config

Now for Zabbix to work with logs let's comment the original access_log line and paste this fragment:

It should be looking like this:

Log result

Check and restart Nginx another time, and let’s get to configuring our Zabbix.

Configuring Zabbix

Assuming that all previous instructions have been completed, you now only need to create a host for this server and add Nginx by Zabbix agent template to it, or add it to an already existing one.

Assign the template to the host running Nginx by going to Configuration → Hosts → Select the host → Templates → Add.

templates
If everything is right you must be able to work with the data which is provided by the template:

  • General metrics: CPU and memory usage, number of connections currently open to the server.
  • Request metrics: The average time to respond to a request, percentage of requests that result in an error, number of requests processed by Nginx per second.
  • SSL metrics: How many handshakes are processed by Nginx per second, the amount of ciphers that are supported by Nginx, and the count of certificate errors that are encountered by Nginx.
  • Uptime: tracks how long Nginx has been running without any downtime.

Graphs

Items

The Zabbix template also includes a number of triggers alerting you when there is a problem with your Nginx server. These triggers notify you of problems such as high CPU usage, high memory usage, high error rate, and downtime.

For example:

  • High CPU usage trigger: This trigger will alert you when the CPU usage on your Nginx server exceeds a certain threshold.
  • High memory usage trigger: This trigger will alert you when the memory usage on your Nginx server exceeds a certain threshold.
  • High error rate trigger: This trigger will alert you when the error rate on your Nginx server exceeds a certain threshold.
  • Downtime trigger: This trigger will alert you if your Nginx server stops working.

And some items if you want to check something not covered in default graphs or triggers.

Triggers

Conclusion

You have explored how to get Nginx ready for monitoring with Zabbix and add a suitable template to Zabbix which allows you to proactively monitor your server and quickly resolve any issues that may arise.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 4
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.