You need to enable JavaScript to run this app.
Volcengine Managed Service for Prometheus

Volcengine Managed Service for Prometheus

Copy page
Download PDF
Exporter integration
NGINX exporter integration
Copy page
Download PDF
NGINX exporter integration
Volcengine Managed Service for Prometheus (VMP) monitors the operational status of NGINX by using the exporter. This topic describes how to deploy nginx-exporter in a cluster and monitor NGINX.​
Background​
The NGINX application exposes some metrics on the stub_status page. Nginx-exporter collects the metrics of a single NGINX instance and converts the metrics into monitoring data that can be used by Prometheus.​
Prerequisites​
  • VMP​
  • VKE​
  • A Volcano Engine root user has been created, and VKE has been activated.​
  • The VKE cluster has been integrated with VMP. For details, see VKE integration.​
  • Grafana has been deployed and integrated with the workspace.​
Procedure​
Step 1: Enable the stub_status feature​
NGINX exposes its status data on the stub_status page. After you deploy NGINX, you need to first check whether the stub_status feature is enabled.​
  1. In the environment where NGINX is located, execute the following command to check whether the stub_status feature is enabled in NGINX:​
​
nginx -V 2>&1 | grep -o with-http_stub_status_module​
​
If the command output is with-http_stub_status_module, it indicates that the stub_status feature is enabled for NGINX.​
2. Modify the nginx.conf configuration file to specify the port number and URL to access the stub_status page.​
​
server {​
listen 8080;​
location /stub_status {​
stub_status on;​
access_log off;​
}​
}​
​
  1. Reload NGINX to make the configuration take effect.​
​
nginx -t​
nginx -s load​
​
  1. After the configuration is complete, you can view NGINX metrics by using the URL in your local environment.​
​
curl http://127.0.0.1:8080/stub_status​
​
The following section shows the expected response result.​
​
Active connections: 45​
server accepts handled requests​
1056958 1156958 4491319​
Reading: 0 Writing: 25 Waiting : 7​
​
Step 2: Deploy nginx-exporter​
  1. Log in to the VKE console.​
  1. In the left navigation pane, click Cluster. In the cluster list on the right side, find the target cluster.​
  1. Click the name of the cluster to go to the cluster details page.​
  1. Click Workload > Deployment in the left navigation pane. Click Create with Yaml to deploy nginx-exporter.​
​
apiVersion: apps/v1​
kind: Deployment​
metadata:​
name: nginx-exporter # Specify the name of the exporter.​
namespace: volcano-metrics # Specify the namespace of the exporter.​
labels:​
app-name: nginx-exporter # Configure the labels of the exporter.​
spec:​
replicas: 1 # Specify the number of replicas for the exporter.​
selector:​
matchLabels:​
app: nginx-exporter​
template:​
metadata:​
labels:​
app: nginx-exporter​
spec:​
containers:​
- args: ​
- "-nginx.scrape-uri=http://<nginx-ip>:8080/stub_status" # Configure the metric scraping page path of the exporter, which must be consistent with the stub_status page path of NGINX.​
name: nginx-exporter # Specify the container name.​
image: nginx/nginx-prometheus-exporter:latest # Pull the exporter image from Docker Hub.​
ports:​
- containerPort: 9113 # Specify the container port number.​
app-name: metric-port # Specify the container port name.​
​
Step 3: Configure service discovery​
  1. Click Workload > Resource Explorer in the left navigation pane.​
  1. Click Create with Yaml to configure service discovery by using PodMonitor.​
  • Select Custom from the Type drop-down menu.​
  • Enter the YAML configuration in the Yaml field.​
​
apiVersion: monitoring.coreos.com/v1​
kind: PodMonitor​
metadata:​
name: nginx-exporter # Specify the name of PodMonitor.​
namespace: volcano-metrics # Specify the namespace of PodMonitor.​
labels: ​
volcengine.vmp: "true" # Configure the labels for PodMonitor to allow the labels to be identified by prometheus-agent.​
spec:​
podMetricsEndpoints:​
- interval: 30s​
port: metric-port # Specify the container port name of the exporter.​
path: /metrics # Specify the URI path for metric exposure. The value is /metrics by default if it is not specified.​
namespaceSelector:​
matchNames: ​
- volcano-metrics # Specify the namespace where the exporter is located.​
selector: ​
matchLabels:​
app-name: nginx-exporter # Specify the label value of the exporter to locate and select the target pod.​
​
Validate results​
  1. Execute the following command to configure Grafana port forwarding:​
​
kubectl port-forward service/grafana 3000:3000 -n volcano-metrics​
​
  1. Open a browser in your local environment (Linux/Mac), paste localhost:3000 into the address bar, and then press Enter to go to the Grafana login page. Log in to Grafana by using the default username admin and password admin.​
  • ​alt​​
  1. After you log in to Grafana, you can create an NGINX dashboard to view information about NGINX.​
  • ​alt​​
tip​
For detailed parameters of nginx-exporter, refer to nginx-exporter.​
​
Last updated: 2026.10.10 10:16:50