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.
Metric Description nginx_connections_accepted The number of accepted client connections. nginx_connections_active The number of active client connections. nginx_connections_handled The number of handled client connections. nginx_connections_reading The number of client connections that are used for reads. nginx_connections_waiting The number of waiting client connections. nginx_connections_writing The number of client connections that are used for write-backs. nginx_http_requests_total The total number of client requests. nginx_up Indicates whether an NGINX exporter runs properly. nginxexporter_build_info The 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:
- 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.
- 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
- 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
anddeny all
specify that only local access is allowed. To allow access from the NGINX exporter, comment out these two lines of code, or change127.0.0.1
to the IP address of the NGINX exporter.
- The value of location must be
- Restart NGINX.
nginx -t nginx -s reload
- 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:
Step 2: Install and configure an NGINX exporter of the new version
Procedures
Procedure 1: Integration Center of Managed Service for Prometheus
- Log on to the ARMS console.
- In the left-side navigation pane, choose .
- 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
- Log on to the ARMS console.
- 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.
- 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.
- 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.
- If you install an NGINX exporter of the new version for the first time, perform the following operation:
- On the Configuration tab in the STEP2 section, configure the parameters and click OK. The following table describes the parameters.
Parameter Description Exporter Name The 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) Address The URL that is used to access the NGINX service. Nginx(new) Port The 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.