All Products
Search
Document Center

:Nginx integration

Last Updated:Jun 20, 2026

This topic describes how to integrate Nginx with Managed Service for Prometheus. Nginx is a high-performance, open-source web server that supports features such as reverse proxy, load balancing, and HTTP caching. Managed Service for Prometheus collects key Nginx metrics, including request counts, byte sizes, and response times. Managed Service for Prometheus provides ready-to-use dashboards to help administrators understand server performance, optimize configurations, and troubleshoot issues.

Background information

View Nginx metrics in the Integration Center of the ARMS console. In the Integration Center, search for the Nginx component, select the Collect Metrics tab, and then switch to the Kubernetes Environment tab. You can view the metrics supported for Nginx, including nginx_connections_accepted, nginx_connections_active, nginx_connections_handled, nginx_connections_reading, nginx_connections_waiting, nginx_connections_writing, nginx_http_requests_total, nginx_up, and nginxexporter_build_info. The metric types include COUNTER and GAUGE, and all metrics are in the 'common' group.

Prerequisites

  • The Nginx service is installed and running.

  • To enable Stub Status monitoring for Nginx, install the ngx_http_stub_status_module module.

    How to install the ngx_http_stub_status_module module

    1. Check whether the ngx_http_stub_status_module module is installed.

      nginx -V 2>&1 | grep -o with-http_stub_status_module
      • If the following output is returned, the ngx_http_stub_status_module module is installed.

        [root@xxx ~]# nginx -V 2>&1 | grep -o with-http_stub_status_module
        with-http_stub_status_module
        [root@xxx ~]#
      • If no output is returned, install the module by running the following commands:

        wget http://nginx.org/download/nginx-1.13.12.tar.gz
        tar xfz nginx-1.13.12.tar.gz
        cd nginx-1.13.12/
        ./configure --with-http_stub_status_module
        make
        make install
    2. Enable the ngx_http_stub_status_module module to query the Nginx status.

      location /nginx_status {
        stub_status on;
        allow 127.0.0.1;  #only allow requests from localhost
        deny all;   #deny all other hosts 
       }
      Note
      • The location path must be named nginx_status.

      • The allow 127.0.0.1 and deny all directives allow only local access. To allow access from the Nginx exporter, you can comment out these two lines or replace 127.0.0.1 with the IP address of the Nginx exporter.

    3. Restart Nginx.

      nginx -t
      nginx -s reload 
    4. Optional: Verify that the ngx_http_stub_status_module module is started.

      curl http://127.0.0.1/nginx_status

      If the following output is returned, the ngx_http_stub_status_module module is started.

      [root@xxx ~]# curl 12xxx/nginx_status
      Active connections: 1
      server accepts handled requests
       177 177 3956
      Reading: 0 Writing: 1 Waiting: 0
      [root@xxx ~]#
  • To enable VTS monitoring for Nginx, install the nginx-module-vts module.

    How to install the nginx-module-vts module

    1. Download the nginx-module-vts module.

      Note

      https://github.com/vozlt/nginx-module-vts.git

    2. Configure compilation settings.

      1. Add the nginx-module-vts module during Nginx compilation.

        --add-module=/path/to/nginx-module-vts
      2. Download the official Nginx package and compile the nginx-module-vts module into it.

        ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_sysguard_module  --add-module=nginx-module-vts
    3. Install the nginx-module-vts module.

      make && make install
    4. Configure Nginx. Modify the nginx.conf file and add the monitoring endpoint.

      http {
          vhost_traffic_status_zone;
              vhost_traffic_status_filter_by_host on;
          ...
          server {
              ...
              location /status {
                  vhost_traffic_status_display;
                  vhost_traffic_status_display_format html;
              }
          }
      }

      Enable vhost filtering in the configuration file.

      vhost_traffic_status_filter_by_host on
      Note

      If Nginx is configured with multiple server_name directives, this feature allows the system to collect traffic statistics for each server name. Otherwise, all traffic is attributed to the first server_name by default.

      If you do not need to collect traffic statistics for a specific server block, you can disable vhost_traffic_status. The ellipses (...) in the example indicate omitted content.

      server {
      ...
      vhost_traffic_status off;
      ...
      }
    5. Verify that the nginx-module-vts module is installed.

      curl http://127.0.0.1/status

Integrate Nginx

  1. Sign in to the ARMS console. In the left-side navigation pane, go to Integration Center and click the Nginx card.

  2. Configure the integration parameters.

    1. Select the environment type.

      • Kubernetes Environment: The monitoring target runs in an ACK cluster.

      • ECS (VPC): The monitoring target runs on an ECS instance.

    2. Select an ACK cluster or an ECS instance.

    3. Configure the integration.

      Kubernetes environment

      Parameter

      Description

      Example

      Integration name (optional)

      A custom name for the integration.

      nginxtest123

      Enable Nginx for stub status monitoring

      Enables or disables this monitoring feature.

      It provides statistics on Nginx requests and connections.

      Note

      Before you enable this option, make sure that the ngx_http_stub_status_module module is installed.

      N/A

      Enable Nginx for VTS monitoring

      Enables or disables this monitoring feature.

      This option uses the nginx-module-vts module, which typically requires manual compilation, to collect data. It provides metrics such as Nginx request counts, byte sizes, and response times.

      Note

      Before you enable this option, make sure that the nginx-module-vts module is installed.

      N/A

      Nginx host

      The following types are supported:

      • The in-cluster access address of the Nginx service

      • The internal IP address of the cluster where the service resides

      • The public IPv4 address of the service

      nginx-server.namespace

      Nginx port

      The port of the Nginx service.

      80

      Metric collection interval (seconds)

      The metric collection interval. The default is 15 seconds.

      15

      ECS (VPC)

      Parameter

      Description

      Example

      Integration name (optional)

      A custom name for the integration.

      nginxtest321

      Enable Nginx for stub status monitoring

      Enables or disables this monitoring feature.

      It provides statistics on Nginx requests and connections.

      N/A

      Enable Nginx for VTS monitoring

      Enables or disables this monitoring feature.

      This option uses the nginx-module-vts module, which typically requires manual compilation, to collect data. It provides metrics such as Nginx request counts, byte sizes, and response times.

      Note

      Before you enable this option, make sure that the nginx-module-vts module is installed.

      N/A

      Nginx host

      The following types are supported:

      • The in-cluster access address of the Nginx service

      • The internal IP address of the cluster where the service resides

      • The public IPv4 address of the service

      nginx-server.namespace

      Nginx port

      The port of the Nginx service.

      80

      Metric collection interval (seconds)

      The metric collection interval. The default is 15 seconds.

      15

      Custom Tags

      Adds custom key-value pair tags to metrics collected by Prometheus, which allows for more granular organization, querying, monitoring, and analysis in tools such as Grafana. For more information, see Inject a custom tag into metrics for an instance in a VPC environment.

      Note
      • Tag keys cannot contain special characters such as hyphens (-), periods (.), or percent signs (%) because these characters have special meanings in Prometheus.

      • Injected tags must be in a valid key-value format that Prometheus allows.

      test1:aaa

View monitoring information

To view integrated components, click Integration Management in the left-side navigation pane. Click an integration card to view its details, including targets, metrics, dashboards, alerts, service discovery configurations, and exporters. On the Self-monitoring page for the Kubernetes environment, select the Prometheus Agent tab. You can filter the data by using the job, instance, and agent drop-down lists. The page displays the following monitoring panels: Agent running status (expected replicas, running replicas, number of targets, and total series scraped); Agent discovery/scraping exceptions (number of job service discovery exceptions, job scraping exceptions, and target scraping exceptions; exceptions are highlighted in red); Agent configuration delivery exceptions (sendConfig exceptions and sendTargets exceptions; normal status is indicated in green); Agent collection and processing exceptions; and Agent running version. At the bottom, the Agent status overview table lists metrics for each agent, such as heartbeat, targets, series, writeArms, pod_name, memoryLimit, and cpuLim.