NGINX Monitoring with Prometheus

Enable the stub status module

Example Configuration below. This will create a HTTP server on port 81 only available from localhost. This goes inside the http {} section

server { 
		listen localhost:81;
		location /metrics {
			stub_status on;


Make sure to restart the NGINX service

service nginx restart

This is what the /metrics endpoint will look like

curl localhost:81/metrics
Active connections: 2 
server accepts handled requests
 13 13 25 
Reading: 0 Writing: 1 Waiting: 1

Install the NGINX Prometheus Exporter from GitHub


cd /tmp

tar -xf nginx-prometheus-exporter-0.7.0-linux-amd64.tar.gz
mv nginx-prometheus-exporter /usr/local/bin

useradd -r nginx_exporter

# Create Systemd Service File
nano /etc/systemd/system/nginx_prometheus_exporter.service
systemctl daemon-reload
service nginx_prometheus_exporter status
service nginx_prometheus_exporter start
Description=NGINX Prometheus Exporter

ExecStart=/usr/local/bin/nginx-prometheus-exporter \
    -web.listen-address=private_IP_here:9113 \



Once the exporter has started you should be able to CURL the exporter and the output should look like this.

If you have ufw enabled you have to allow tcp port 9113

ufw allow proto tcp from any to any port 9113

Now just tell prometheus to scrape the exporter!

  - job_name: 'nginx'
    - targets: ['']

Replace with the IP of the web.listen-address

Get $200 in cloud credits from DigitalOcean using my link: