Alibaba Cloud Managed Service for Prometheus allows you to install and configure NGINX exporters. Managed Service for Prometheus also provides out-of-the-box dashboards that you can use to monitor your applications. This topic describes how to install and configure NGINX exporters of the new version.

Prerequisites

The NGINX service is installed and runs as expected.

Background information

  • The NGINX status monitoring module (ngx_http_stub_status_module) collects statistics about the number of requests that are received and processed by the NGINX service.
  • ngx_http_stub_status_module is installed for NGINX exporters of the new version.
  • The following table describes the metrics of NGINX exporters of the new version.
    MetricDescription
    nginx_connections_acceptedThe number of accepted client connections.
    nginx_connections_activeThe number of active client connections.
    nginx_connections_handledThe number of handled client connections.
    nginx_connections_readingThe number of client connections that are used for reads.
    nginx_connections_waitingThe number of waiting client connections.
    nginx_connections_writingThe number of client connections that are used for write-backs.
    nginx_http_requests_totalThe total number of client requests.
    nginx_upIndicates whether an NGINX exporter runs properly.
    nginxexporter_build_infoThe build information about the NGINX exporter.

Step 1: Install ngx_http_stub_status_module

If your NGINX service is running on an Elastic Compute Service (ECS) instance, perform the following steps to install an NGINX exporter:

  1. Check whether ngx_http_stub_status_module is installed.
    nginx -V 2>&1 | grep -o with-http_stub_status_module
    • If the following information appears, it indicates that ngx_http_stub_status_module is installed. cw_prom_exporter_nginx_module
    • If the preceding information does not appear, ngx_http_stub_status_module is not installed. Run the following commands to install the module:
      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. Start ngx_http_stub_status_module to query the status of the NGINX service.
    location /nginx_status {
      stub_status on;
      allow 127.0.0.1;  #only allow requests from localhost
      deny all;   #deny all other hosts 
     }
    Note
    • The value of location must be nginx_status.
    • allow 127.0.0.1 and deny all specify that only local access is allowed. To allow access from the NGINX exporter, comment out these two lines of code, or change 127.0.0.1 to the IP address of the NGINX exporter.
  3. Restart NGINX.
    nginx -t
    nginx -s reload 
  4. Optional:Check whether the ngx_http_stub_status_module module is started.
    curl http://127.0.0.1/nginx_status
    The following output indicates that the ngx_http_stub_status_module module is started: fh

Step 2: Install and configure an NGINX exporter of the new version

Procedures

Procedure 1: Integration Center of Managed Service for Prometheus

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Prometheus Service > Prometheus Instances.
  3. Click the name of the Prometheus instance instance that you want to manage to go to the Integration Center page.

Procedure 2: Integration Center in the ARMS console

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, click Integration Center. On the Integration Center page, click Nginx(new) in the Application Components section. In the Monitor Nginx(new) panel that appears, follow the on-screen instructions to add the exporter.

Install and configure an NGINX exporter of the new version

This section describes how to install and configure an NGINX exporter of the new version on the Integration Center page of Managed Service for Prometheus.

  1. Install an NGINX exporter of the new version.
    • If you install an NGINX exporter of the new version for the first time, perform the following operation:
      In the uninstalled section of the Integration Center page, find the Nginx(new) exporter and click Install. vdj
    • If you have installed an NGINX exporter of the new version, you need to add the exporter again:

      In the Installed section of the Integration Center page, click Add on the Nginx(new) exporter.

  2. On the Configuration tab in the STEP2 section, configure the parameters and click OK. The following table describes the parameters.
    ParameterDescription
    Exporter NameThe name of the NGINX exporter of the new version. The name must meet the following requirements:
    • The name can contain only lowercase letters, digits, and hyphens (-) and cannot start or end with a hyphen (-).
    • The name must be unique.
    Note If you do not specify this parameter, the system uses the default name, which consists of the exporter type and a numeric suffix.
    Nginx(new) AddressThe URL that is used to access the NGINX service.
    Nginx(new) PortThe port number of the NGINX service. Example: 80.
    Note You can view the monitoring metrics on the Metrics tab in the STEP2 section.

    The installed components are displayed in the Installed section of the Integration Center page. Click the component. In the panel that appears, you can view information such as targets, metrics, dashboard, alerts, service discovery configurations, and exporters. For more information, see Integration center.