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, configure a custom log format:
log_format amplify '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time';
Apply it to your access log:
access_log /var/log/nginx/access.log amplify;
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.