Complete the code to check the current active connections in NGINX.
curl http://localhost/nginx_status | grep [1]The Active keyword shows the number of active connections in the NGINX status output.
Complete the code to enable the stub_status module in NGINX configuration.
location /nginx_status {
stub_status [1];
allow 127.0.0.1;
deny all;
}The stub_status on; directive enables the status module in NGINX.
Fix the error in the NGINX log format to include request time.
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $[1];
The variable $request_time logs the time spent processing the request.
Fill both blanks to create a map that sets a variable based on request time threshold.
map $request_time $slow_request {
default [1];
~^[3-9]\.|^[1-9][0-9]+ [2];
}The map sets $slow_request to 0 by default and 1 if the request time is 3 seconds or more.
Fill all three blanks to log slow requests only.
access_log /var/log/nginx/slow.log combined if=[1]; map $request_time $slow_request { default [2]; ~^[3-9]\.|^[1-9][0-9]+ [3]; }
The access log uses if=$slow_request to log only slow requests. The map sets default to 0 (not slow) and 1 for slow requests.