Project: HertzBeat (Observability and Analysis / Observability)
File: nginx.md

id: nginx title: Monitoring Nginx sidebar_label: Nginx Monitor keywords: [open source monitoring tool, open source java monitoring tool, monitoring nginx metrics] Collect and monitor the general performance Metrics of Nginx. Protocol UseNginx 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. Check if `ngxhttpstubstatusmodule` has been added ```shell nginx -V ``` View whether it contains `--with-httpstubstatus_module`, if not, you need to recompile and install Nginx. Compile and install Nginx, add `ngxhttpstubstatusmodule` module Download Nginx and unzip it, execute the following command in the directory ```shell ./configure --prefix=/usr/local/nginx --with-httpstubstatus_module make && make install ``` Modify Nginx configure file Modify the `nginx.conf` file and add the monitoring module exposed endpoint, as follows: ```shell server { listen 80; # port server_name localhost; location /nginx-status { stub_status on; access_log on; } } ``` Reload Nginx ```shell nginx -s reload ``` Access `http://localhost/nginx-status` in the browser to view the Nginx monitoring status information. ```shell wget https://github.com/zls0424/ngxreqstatus/archive/master.zip -O ngxreqstatus.zip unzip ngxreqstatus.zip patch -p1 < ../ngxreqstatus-master/write_filter.patch ./configure --prefix=/usr/local/nginx --add-module=/path/to/ngxreqstatus-master make -j2 make install ``` Modify Nginx configure file update `nginx.conf` file, add status module exposed endpoint, as follows: ```shell http { reqstatuszone servername $servername 256k; reqstatuszone serveraddr $serveraddr 256k; reqstatus servername server_addr; server { location /req-status { reqstatusshow on; } } } ``` Reload Nginx ```shell nginx -s reload ``` Access `http://localhost/req-status` in 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` | Parameter name | Parameter help description | ||| | Monitoring Host | Monitored IPV4, IPV6 or domain name. NoteWithout protocol header (eg: https://, http://) | | Monitoring name | Identify the name of this monitoring. The name needs to be unique | | Port | Port provided by Nginx | | Timeout | Allow collection response time | | Collection interval | Interval time of monitor periodic data collection, unit: second, and the minimum interval that can be set is 30 seconds | | Whether to detect | Whether to detect and check the availability of monitoring before adding monitoring. Adding and modifying operations will continue only after the detection is successful | | Description remarks | For more information about identifying and describing this monitoring, users can note information here | | Metric name | Metric unit | Metric help description | |-|-|| | accepts | | Accepted connections | | handled | | Successfully processed connections | | active | | Currently active connections | | dropped | | Discarded connections | | requests | | Client requests | | reading | | Connections performing read operations | | writing | | Connections performing write operations | | waiting | | Waiting connections | | Metric name | Metric unit | Metric help description | |-|-|| | zone_name | | Group category | | key | | Group name | | max_active | | Maximum concurrent connections | | max_bw | kb | Maximum bandwidth | | traffic | kb | Total traffic | | requests | | Total requests | | active | | Current concurrent connections | | bandwidth | kb | Current bandwidth |