Alibaba Cloud Managed Service for Prometheus allows you to install and configure NGINX exporters with a few clicks. 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 an NGINX exporter of the earlier version.

Background information

  • The nginx-module-vts module is installed for NGINX exporters of the earlier version.
  • The following table describes the metrics of NGINX exporters of the earlier version.
    MetricTypeDescription
    nginx_server_requestsServerThe number of server requests.
    nginx_server_bytesServerThe number of bytes processed by the server.
    nginx_server_cacheServerThe cache of the server.
    nginx_filter_requestsFilterThe number of filter requests.
    nginx_filter_bytesFilterThe number of bytes processed by the filter.
    nginx__filter_responseMsecFilterThe response time of the filter.
    nginx_upstream_requestsUpstreamsThe number of upstream requests.
    nginx_upstream_bytesUpstreamsThe number of upstream bytes.
    nginx_upstream_responseMsecUpstreamsThe response time to upstream requests.

Prerequisites

The NGINX service is installed and is running. The nginx-module-vts module is installed. To install the nginx-module-vts module, perform the following steps:

  1. Download the nginx-module-vts module.
    Note shell > git clone git://github.com/vozlt/nginx-module-vts.git
  2. Compile and install the nginx-module-vts module.
    1. Add the nginx-module-vts module to the NGINX configuration file.
      --add-module=/path/to/nginx-module-vts
    2. Download the official software package of NGINX and compile it with the nginx-module-vts module added.
      ./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. Modify the NGINX configuration file and add a monitoring interface.
    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;
            }
        }
    }
    We recommend that you run the following command to enable vhost filtering:
    vhost_traffic_status_filter_by_host on
    Note If you configure multiple server names, you can enable vhost filtering to ensure that the system collects traffic statistics based on different server names. If you do not enable vhost filtering, the system determines that all traffic belongs to the first server name.
    If you do not need to monitor traffic by region, you can run the following command to disable vhost filtering. The ellipsis (...) in the following command indicates the code that is omitted.
    server {
    ...
    vhost_traffic_status off;
    ...
    }
  5. Check whether the nginx-module-vts module is installed.
    curl http://127.0.0.1/status

Entry points

Procedure 1: Integration Center of Managed Service for Prometheus

  1. Log on to the Managed Service for Prometheus console.
  2. In the left-side navigation pane, click Monitoring List.
  3. Click the name of the Prometheus instance instance that you want to manage to go to the Integration Center page.

Entry point 2: Integration Center in the ARMS console

  1. Log on to the Application Real-time Monitoring Service (ARMS) console.
  2. In the left-side navigation pane, click Integration Center. The Integration Center page appears. In the Application Components section, find Nginx (old) and click Install. In the Monitor NGINX (Old) panel, configure the parameters to install the NGINX exporter based on the instructions in the console.

Install an NGINX exporter

The following example shows how to install an NGINX exporter in Integration Center.

  1. Install an NGINX exporter.
    • If you install an NGINX exporter for the first time, perform the following operations:

      In the uninstalled section of the Integration Center page, find the NGINX exporter and click Install.

    • If you have installed an NGINX exporter, you need to perform the following operations to add the exporter again:

      In the Installed section of the Integration Center page, find the NGINX exporter and click Add.

  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. 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 configure this parameter, the system uses the default name, which consists of the exporter type and a numeric suffix.
    NGINX (Old) AddressThe URL that is used to access the NGINX exporter.
    NGINX (Old) PortThe port number of the NGINX exporter. Example: 80.
    Important
    • You must first install the nginx-module-vts module. This module allows you to access virtual host status information and provides output data in the JSON format.
    • 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.