All Products
Search
Document Center

:Install and configure an NGINX exporter

Last Updated:Aug 03, 2023

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 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 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. The configuration of NGINX Conf. 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

Entry point 1

  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.

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. In the Application Components section, find the Nginx (old) component and click Add. In the panel that appears, configure an Nginx (old) exporter as prompted.

Configure an NGINX exporter

This section describes how to configure an NGINX exporter in the integration center of the Prometheus instance. Perform the following steps:

  1. Configure an NGINX exporter.
    • If you install the NGINX component for the first time, perform the following operation:
      In the Not Installed section of the Integration Center page, find the NGINX component and click Install.
    • If you have installed the NGINX component, you must add the component again.

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

  2. On the Configuration tab in the STEP2 section of the panel that appears, set the parameters and click OK.
    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 specify this parameter, the system uses the default name, which consists of the exporter type and a numeric suffix.
    NGINX (Old) URLThe URL that is used to access the NGINX server.
    NGINX (Old) PortThe port number of the NGINX server. Example: 80.
    Important
    • You must first install the NGINX virtual host traffic status module (nginx-module-vts). This module outputs 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.