Nginx monitoring, when, how and what


When we talk about NGINX, we are clear on the fact that we’re discussing one of the applications that has been revolutionizing the web server industry. It has not only grown bigger in terms of use than other solutions like IIS, but also it’s taking a big chunk of the pie from the general web server market (lead by Apache), with over 140 million servers running on this application. 

Due to the growth in the number of web servers that run NGINX, it’s becoming more necessary to not only monitor these systems, but also they should integrate in the global monitoring for any IT infrastructure. 

To perform a correct monitoring scheme on NGINX, the software offers two possible alternatives:

  • its module nginx_status, included with all versions of NGINX 
  • the recently launched NGINX Plus Status Module, available on the paid version of the app.

Next, we’ll list the different traits corresponding to each of the different ways we can monitor NGINX, in order to end up giving you some recommendations on when to use one or another and how to use them.

NGINX Status Module

In order to activate this module we need to insert a URL we’ll associate to the monitoring module in the NGINX configuration.

   location /server-status
                        stub_status on;
                        access_log   off;

                        deny all;

With this directive and, after having configured NGINX to allow it to show monitoring data via the parameter –with-http_stub_status_module, we’ll be able to access the /server-status URL for our server, receiving varied data related to our server’s status. Data like the number of active connections, amount of queued queries, amount or read/write requests, and number of active customers. 

Nginx Plus Status Module

This is the module that NGINX has developed to be able to offer a larger amount of information on our server’s status. One of the  large advantages that this module has is that, apart from giving a lot more information, it also offers a console to be able to check your NGINX server’s status in real time. 

Apart from being able to see all the information on a dashboard, this module allows us to access the following data that the previous module wouldn’t allow: both information related to the number of mistaken requests and code (4xx, 5xx…) such as information on the cache, that’s shown with this module.

Another extra feature on the NGINX Plus Status module is that it allows users to see the performance data grouped according to ‘zones’. 

Nginx status, Nginx Plus Status or simple monitoring

On this occasion the question has to be if we wish to install the Open Source edition of NGINX, or if we’ll choose to pay for NGINX Plus. When it comes to taking this decision we must know how to fundamentally stick to the needs that our web infrastructure has, rather than basing the decision on the monitoring process itself. Do we need load balancing? How about persistent login? Is our server reset so complex that we need to change immediately change configurations without resetting? If the answer to these questions is “yes”, then you should probably think about purchasing an NGINX Plus license. 

Whether we have the Plus version of NGINX or not, it is highly recommendable that you perform good monitoring on your web infrastructure, regardless of what size it is, because if you’re on the Internet, your platform’s unavailability can generate costs that, on many occasions cannot be measured. 

If your infrastructure is simple and only runs simple web pages, it’s quite recommendable to use HTTP monitoring services such as uptimerobot, for example. Going straight to the point: is my webpage active, yes or no? In this case, we wouldn’t need monitoring via NGINX and its status module.

In case our infrastructure is more complex, we have various databases, or a network with multiple nodes, routers or switches; then it’s recommended we use a server monitoring software. 

This software will allow adding all your network elements on to the same monitoring dashboard, and will send alerts based on their status. When there’s an issue in our systems, it’s very important that we know where it’s coming from and what’s causing it as soon as possible, in order to counteract the possible issues generated from unavailability. 
For this case, if we have the Plus version of NGINX, it’s quite recommendable to include the NGINX Plus Status module on our monitoring dashboard. For Pandora FMS this can be done following the steps in the video below.

In case you don’t have the paid version of NGINX we recommend you create a script that helps the monitoring system digest the information coming from the NGINX Status module. The main data can be obtained by calling on the URL where the NGINX Status module has been configured. Other important data like response times and error codes will require us to resort to the server logs and process them through a script in order to be able to show them on our alert and monitoring console. For further information, read this article on NGINX monitoring. 

We hope this was all useful and that after reading this article, whatever your infrastructure is, you feel ready to monitor it correctly.