启用Nginx状态模块:
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
输出示例:
Active connections: 291
server accepts handled requests
16630948 16630948 31070465
Reading: 6 Writing: 179 Waiting: 106
nginx-prometheus-exporter
收集指标log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time';
error_log /var/log/nginx/error.log warn;
request_time
超过阈值的请求upstream_response_time
$remote_addr
分析用户分布需要更详细的某方面信息或遇到具体问题,可以进一步探讨。