Configuring NGINX for Monitoring

To collect detailed metrics, NGINX needs to be configured with the stub_status module enabled. This page explains the recommended configuration.

Enabling stub_status

Add the following location block to your NGINX configuration:

server {
    listen 127.0.0.1:80;
    server_name localhost;

    location /nginx_status {
        stub_status on;
        allow 127.0.0.1;
        deny all;
    }
}

Then reload NGINX:

sudo nginx -t && sudo systemctl reload nginx

Enabling Access Log Metrics

For detailed request metrics — including Traffic Volume and Gzip Compression Ratio — configure a custom log format that exposes the variables Amplify parses:

log_format amplify '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent $bytes_sent $request_length '
                    '"$http_referer" "$http_user_agent" '
                    '$request_time $upstream_response_time $gzip_ratio';

Apply it to your access log:

access_log /var/log/nginx/access.log amplify;

Each variable in the format above maps to a specific chart on the host detail page:

  • $body_bytes_sent, $bytes_sent, $request_lengthTraffic Volume chart.
  • $request_timeRequest Time chart.
  • $upstream_response_timeUpstream Response Time chart.
  • $gzip_ratioGzip Compression Ratio chart. Requires gzip on; in the server/location that serves the response; NGINX logs - (which Amplify skips) for uncompressed responses, so the chart only reflects compressed traffic.

NGINX Plus Configuration

For NGINX Plus, enable the API endpoint:

server {
    listen 127.0.0.1:8080;

    location /api {
        api write=off;
        allow 127.0.0.1;
        deny all;
    }
}
Tip

The agent automatically detects both stub_status and the Plus API endpoints. Just ensure they're accessible from localhost.