Nginx
Single Machine
The Prometheus Nginx exporter can be used on a standalone machine to collect metrics from an nginx server.
Prerequisite(s)
StackGen Single Machine agent
The StackGen single machine agent should be running on this machine. If that's not the case, [it can be installed using these steps](Individual VMs).
stub_status module
The Nginx server should have the stub_status module enabled for the metrics collection to work. Availability of this module can be checked by running this command:
nginx -V 2>&1 | grep -o with-http_stub_status_module
If this module is not already enabled, it can be enabled by following the steps outlined in this document.
Add a location for stub_status
Update the nginx.conf file and add a location for the stub_status module. This enables the nginx server to return metrics on the configured location URI. Here is an example:
server {
listen localhost;
server_name status.localhost;
keepalive_timeout 0;
access_log off;
allow 127.0.0.1;
deny all;
location /stub_status {
stub_status on;
}
}
For more details, please see - Nginx metrics through stub_status.
Install Nginx Prometheus Metric Exporter
The nginx prometheus exporter can be installed using this command:
# for amd64
curl https://raw.githubusercontent.com/OpsVerseIO/installers/main/prometheus-exporters/install-exporter-amd64.sh | sudo bash -s -- -e nginx
# for arm64
curl https://raw.githubusercontent.com/OpsVerseIO/installers/main/prometheus-exporters/install-exporter-arm64.sh | sudo bash -s -- -e nginx
The agent will begin scraping the metrics automatically. The script will drop the scrape target into /etc/opsverse/targets/, so the agent will begin automatically scraping.