🏃 Deploy nginx-prometheus-exporter to Reverse Proxy hosts

This runbook provides **step-by-step instructions to deploy the nginx-prometheus-exporter to the Reverse Proxy hosts.


1️⃣ Login to an Ansible Control Node

Start by logging into a control node that has Ansible installed and prepare the environment:

cd ~/ansible
source activate
INV=inventory/rproxy/inventory.ini

⚡ Important: Always start on the control node so all subsequent commands run in the correct environment.


2️⃣ Pull the Latest Code

Before making any changes, ensure your local repository is up to date:

git pull origin main   # Pull the latest code

⚡ Important: Pulling the latest code first prevents conflicts and ensures you’re working on the most recent version.


3️⃣ Deploy nginx-prometheus-exporter

Run the following command to deploy nginx-prometheus-exporter:

ansible-playbook -i $INV -k -u ansible playbooks/prometheus/deploy_nginx_prometheus_exporter.yml

⚡ Note: The -k option prompts for SSH password if needed.


4️⃣ Refresh Prometheus Exporter Targets

This repo separates the deployment step from the Prometheus target refresh step. After deploying nginx-prometheus-exporter, refresh the scrape targets so Prometheus begins monitoring the new hosts:

ansible-playbook -i $INV -k -u ansible playbooks/prometheus/deploy_prometheus_exporters.yml

⚡ Important: The exporter deployment installs the service, but the Prometheus refresh step updates the scrape config from the current inventory.


Verify Deployment

After deployment, verify both the exporter and Prometheus target status.

Check the exporter endpoint on a Reverse Proxy host

curl -fsS http://<rproxy-host>:9113/metrics | head

You should see Prometheus-format metrics output.

Check the target list in Prometheus

curl -fsS 'http://<prometheus-host>:9090/api/v1/targets' | jq '.data.activeTargets[] | select(.labels.job=="nginx_exporter")'

You should see the Reverse Proxy hosts listed under the nginx_exporter job.

Check the health query

curl -fsS 'http://<prometheus-host>:9090/api/v1/query?query=up{job="nginx_exporter"}' | jq

Expected result: values should be 1 for healthy hosts.


✅ Notes