📈 Nginx‑prometheus‑exporter

🎯 Purpose

NGINX Prometheus Exporter converts NGINX status data into Prometheus metrics so you can visualize web server health in Grafana and alert on failures later. Use it to monitor:

🏗 Architecture

📊 What the Exporter Provides

Common metric families include:

⚙️ Prerequisites

🚀 Deployment

Example deployment flow:

Deploy or refresh reverse proxy hosts:

source /opt/python_3.12/bin/activate
ansible-playbook -i inventory/rproxy/inventory.ini playbooks/rproxy/deploy_rproxy.yml

Refresh Prometheus exporter targets:

source /opt/python_3.12/bin/activate
ansible-playbook -i inventory/rproxy/inventory.ini playbooks/prometheus/deploy_nginx_prometheus_exporter.yml

Syntax check:

source /opt/python_3.12/bin/activate
ansible-playbook --syntax-check -i inventory/rproxy/inventory.ini playbooks/rproxy/deploy_rproxy.yml

👉 See also: Adding NGINX Exporter to an Inventory

🔍 Prometheus Queries

Exporter health:

up{job="nginx_exporter"}

NGINX reachability:

nginx_up

Active connections:

nginx_connections_active

Request rate:

rate(nginx_http_requests_total[5m])

Total active connections:

sum(nginx_connections_active)

Top busy instances:

topk(5, nginx_connections_active)

📈 Grafana Dashboard Recommendations

Panels:

Variables: instance, group/environment, time range presets.

🧪 Operational Checks

On a target host:

Check exporter service:

systemctl status nginx-prometheus-exporter

Check exporter metrics:

curl -s http://127.0.0.1:<exporter_port>/metrics | head

Check NGINX status endpoint:

curl -s http://127.0.0.1:<nginx_status_port_or_path>

🛠 Troubleshooting

No data in Grafana:

Exporter up but nginx_up = 0:

Intermittent drops:

⭐ Best Practices

📝 Summary

NGINX Exporter provides lightweight visibility into NGINX health using Prometheus and Grafana. Start with exporter health, reachability, and connection/request trends, then layer alerting.