Monitoring is a crucial part of software development, as it helps you keep an eye on performance and resources. Without active monitoring, you’re in the dark, and your apps could go down at any time without your knowledge. This is where tools like Prometheus help. Prometheus is an open-source observability solution that tracks key metrics and gives you visibility into your apps.
However, Prometheus can not automatically connect with all types of apps and resources. In some cases, you need an adapter to translate the metrics that a resource generates into a format that Prometheus can easily understand. Prometheus exporters do just this.
This guide will show you how you can use the <terminal inline>prometheus-nginx-exporter<terminal inline> tool to connect an NGINX server to Prometheus.
What Is The NGINX Prometheus Exporter?
NGINX is one of the most popular web servers used today, and the NGINX Promtheus exporter is a tool you can use to export metrics from your NGINX server and capture them in your Prometheus instance. While NGINX exposes a basic set of metrics via its stub_status module, those metrics are not in a form that Prometheus can scrape. This is where <terminal inline>prometheus-nginx-exporter<terminal inline> helps. It listens to the stub_status endpoint and generates a feed of Prometheus-friendly metrics on an endpoint. You can then configure your Prometheus instance to scrape data from this endpoint and use it to track and analyze the performance of your NGINX server.
How to Use The NGINX Prometheus Exporter
To set up NGINX monitoring using Prometheus, you’ll need the following:
- An NGINX server
- A Prometheus instance
- The prometheus-nginx-exporter
To start, update your NGINX server’s config file to enable the <terminal inline>/metrics<terminal inline> endpoint by adding the following to your <terminal inline>nginx.conf<terminal inline> file:
Visit the <terminal inline>/metrics<terminal inline> route on your NGINX server to see whether metrics have been exposed. You should see a result like this:
Next, install the exporter in a Docker container by running the following command:
Once the exporter is up, you’ll be able to access the following page: <terminal inline>http:<your machine ip>:9113/metrics<terminal inline>, and see a page with detailed metrics from your NGINX server.
Next, set up your Prometheus instance to scrape data from the exporter. You can do this by updating your <terminal inline>prometheus.yaml<terminal inline> file to include the following:
Once everything is set up correctly, you’ll be able to see the NGINX-related metrics in your PromQL autofill suggestions:

You can now use these metrics in PromQL queries to monitor your NGINX server and draw visualizations using other tools, such as Grafana.
Final Thoughts
Prometheus is an all-around, open-source monitoring solution. However, it needs some extra configuration to work with external tools and services. In this guide, you saw how you can export metrics from your NGINX server and capture them in Prometheus using NGINX Prometheus exporter.