NGINX Amplify Agent can collect a number of additional useful metrics described below. To enable these metrics, please make the following configuration changes. More predefined graphs will be added to the Graphs page if the agent finds additional metrics. With the required log format configuration, you'll be able to build more specific custom graphs.
- The access.log log format should include an extended set of NGINX variables. Please add a new log format or modify the existing one — and use it with the
access_log
directives in your NGINX configuration.
log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" sn="$server_name" '
'rt=$request_time '
'ua="$upstream_addr" us="$upstream_status" '
'ut="$upstream_response_time" ul="$upstream_response_length" '
'cs=$upstream_cache_status' ;
- Here's how you may use the extended log format with your access log configuration:
access_log /var/log/nginx/access.log main_ext;
Note. Please bear in mind that by default the agent will process all access logs that are found in your log directory. If you define a new log file with the extended log format that will contain the entries being already logged to another access log, your metrics might be counted twice. Please refer to the agent configuration section above to learn how to exclude specific log files from processing.
- The error.log log level should be set to
warn
.
error_log /var/log/nginx/error.log warn;
Note. Don't forget to reload your NGINX configuration with either kill -HUP
or service nginx reload
.