NGINX plugin

NGINX [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server.

More information on: https://nginx.org

How it works

This plugin analyzes the performance of your Nginx web server. It captures traffic rates, latencies and response codes of http requests sent to the web server by parsing the Nginx access log file.

The plugin can also get some global statistics (the number of connections, the number of workers, etc.) by parsing the status page of the Nginx web server.

Both the access log and server-status require a bit of configuration, see next steps.

The minimal supported version of Nginx is 0.5.38.

Configuration

Configure Nginx status page

For gathering global statistics, the nginx_status page should be enabled.

Enable the status page by adding the following lines inside the http section of your <install-dir>/nginx.conf.

 
http {
    ...
    server {
        listen localhost;

        location /nginx_status {
            stub_status on;
            access_log off;
            allow all;
        }
    }
    ...
}

Restart Nginx to apply these changes.

Configure your Nginx access logs

For the plugin to be able to collect statistics about http requests, the access log has to be enabled. Enable the access log by adding the following lines inside the http section of your <install-dir>/nginx.conf.

Make sure to update the default access_log /var/log/nginx/access.log line with the one provided below.

 
http {
    ...
    log_format CoScale '$server_name "$request" $request_time $status $request_length $bytes_sent';
    access_log /var/log/nginx/access.log CoScale;
    ...
}

Restart Nginx to apply these changes.

Log format

A log format must contain request, $request Example of a log format configuration so that we can have all the information that we need:

$server_name \"$request\" $request_time $status $request_length $bytes_sent

Value Original Value Remarks
Hostname $server_name -
Request $request -
Latency $request_time Latency in seconds with a milliseconds resolution
Status Code $status -
Bytes Received $request_length -
Bytes Sent $bytes_sent -

Other examples of log formats that will work:

"$server_name $remote_addr $remote_user [$time_local] \"$request\" $request_time $status $request_length $bytes_sent \"$sent_http_referer\" \"$sent_http_user\" $query_string"

Active checks

This plugin can be configured to perform a HTTP GET on your Nginx. This active monitoring allows us to calculate the uptime of the service and the response time of the provided URL.

A full URL (eg. http://localhost/test_page) should be provided.

Events

  • Service state

Metrics

Metric name Metric unit
Number of all open connections to Nginx conn
Total accepted connections to Nginx conn
Total handled connections to Nginx conn
Number of requests to Nginx req
Requests per connection to Nginx handled req/conn
Number of reading connections to Nginx conn
Number of writing connections to Nginx conn
Number of waiting connections to Nginx conn