Help Center/ Application Operations Management/ FAQs (2.0)/ Collection Management/ How Do I Enable the Nginx stub_status Module?
Updated on 2024-06-28 GMT+08:00

How Do I Enable the Nginx stub_status Module?

Nginx Prometheus Exporter monitors the Nginx service using the stub_status module. Ensure that this module is enabled. Perform the following operations:
  1. Log in to the node where the Nginx service is deployed and run the following command in the /usr/local/nginx/sbin/nginx directory to check whether the stub_status module is enabled:
    nginx -V 2>&1 | grep -o with-http_stub_status_module
    • If with-http_stub_status_module is returned, the stub_status module is enabled.
    • If no result is returned, enable the stub_status module by setting --with-http_stub_status_module in the configuration file. Example:
      ./configure \
      ## Add the --with-http_stub_status_module parameter.
      --with-http_stub_status_module
      make
      sudo make install
  2. After the stub_status module is enabled, add the following content to the nginx.conf file in the /usr/local/nginx/conf directory: Example:
    server {
     listen 8080;  # Listening port. Set this parameter based on service requirements.
     listen [::]:8080; # IPv6 listening port. Set this parameter based on service requirements.
     server_name localhost; # Set this parameter based on service requirements.
     location = /stub_status { # Path. Set this parameter based on service requirements.
         stub_status on;
         access_log off;
         allow 127.0.0.1;
     }
    }
  3. Restart the Nginx service.