nginx monitoring - Linux, Mac and FreeBSD

The agent can parse the Nginx HttpStubStatusModule output to show the current requests per second and number of connections. It also requires some additional configuration of your Nginx server. Note: These instructions are not for the NginxPlus plugin

This article is outdated and will eventually be removed. See v2 agent NGINX monitoring

If you do not wish to monitor Nginx then leave the default value in the /etc/sd-agent/config.cfg file and the agent will ignore it.

1) Configuring Nginx

a) HttpStubStatusModule module

You first need to ensure the HttpStubStatusModule module is installed. This is not available by default and must be compiled in with the configure line: 

--with-http_stub_status_module

You can check whether HttpStubStatusModule is installed with the following command:

nginx -V 2>&1 | grep -o with-http_stub_status_module

If you get a result you've got it installed already.

b) HttpStubStatusModule configuration

Adding the following lines to your nginx.conf file and within a server { } block will enable the status output. The nginx.conf file can be found in the following location: "/etc/nginx/nginx.conf"

location /status {
  stub_status on;
  access_log off;
  allow 127.0.0.1;
  deny all;
}

You should replace the IP address 127.0.0.1 with your server's public IP address. This will allow the status output to be accessed from a URL http://yourserver/nginx_status. However, it has been restricted to the server IP address which means it can only be accessed from the server itself - this is for security so that only the agent can access the output. If you wish to access it from your browser, you need to add your IP address in. For example: 

allow 127.0.0.1;
allow 127.0.0.2;

You will now need to restart your Nginx web server to allow the changes to take effect.

2) Agent configuration

You need to modify the agent /etc/sd-agent/config.cfg file to be able to get the stats for nginx. Copy and paste the following to the end of "config.cfg".

nginx_status_url: http://127.0.0.1/nginx_status 

If your server's IP was 127.0.0.1 then this URL would be http://127.0.0.1/nginx_status.

3) Restart agent

Restart the agent to start the monitoring.

4) Add graphs

Click the name of your server from the Devices list in your Server Density account then go to the Metrics tab. Click the + Graph button on the right then choose the MySQL metrics to display the graphs. The metrics will also be available to select when building dashboard graphs.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.