Monitoring Nginx
Collect and monitor the general performance Metrics of Nginx.
Protocol Use:Nginx
Need Enable ngx_http_stub_status_module And ngx_http_reqstat_module Module
If you want to monitor information in 'Nginx' with this monitoring type, you need to modify your nginx configure file for enable the module monitor.
Enable ngx_http_stub_status_module
-
Check if
ngx_http_stub_status_modulehas been addednginx -VView whether it contains
--with-http_stub_status_module, if not, you need to recompile and install Nginx. -
Compile and install Nginx, add
ngx_http_stub_status_modulemoduleDownload Nginx and unzip it, execute the following command in the directory
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
make && make install -
Modify Nginx configure file
Modify the
nginx.conffile and add the monitoring module exposed endpoint, as follows:# modify nginx.conf
server {
listen 80; # port
server_name localhost;
location /nginx-status {
stub_status on;
access_log on;
#allow 127.0.0.1; #only allow requests from localhost
#deny all; #deny all other hosts
}
} -
Reload Nginx
nginx -s reload -
Access
http://localhost/nginx-statusin the browser to view the Nginx monitoring status information.
Enable ngx_http_reqstat_module
-
Install
ngx_http_reqstat_module# install `ngx_http_reqstat_module`
wget https://github.com/zls0424/ngx_req_status/archive/master.zip -O ngx_req_status.zip
unzip ngx_req_status.zip
patch -p1 < ../ngx_req_status-master/write_filter.patch
./configure --prefix=/usr/local/nginx --add-module=/path/to/ngx_req_status-master
make -j2
make install -
Modify Nginx configure file
update
nginx.conffile, add status module exposed endpoint, as follows:# modify nginx.conf
http {
req_status_zone server_name $server_name 256k;
req_status_zone server_addr $server_addr 256k;
req_status server_name server_addr;
server {
location /req-status {
req_status_show on;
#allow 127.0.0.1; #only allow requests from localhost
#deny all; #deny all other hosts
}
}
} -
Reload Nginx
nginx -s reload -
Access
http://localhost/req-statusin the browser to view the Nginx monitoring status information.
Refer Doc: https://github.com/zls0424/ngx_req_status
⚠️Attention: The endpoint path of the monitoring module is /nginx-status /req-status