You've already forked nginx_exporter
mirror of
https://github.com/nginxinc/nginx-prometheus-exporter.git
synced 2025-11-03 07:53:15 +03:00
NGINX Prometheus Exporter with systemd-activated socket
This example shows how to run NGINX Prometheus Exporter with systemd-activated socket.
Table of Contents
Prerequisites
- Linux machine with systemd.
- NGINX Prometheus Exporter binary in
/usr/local/bin/nginx-prometheus-exporteror a location of your choice. See the main README for installation instructions. - NGINX or NGINX Plus running on the same machine.
Customization
Modify nginx_exporter.service and nginx_exporter.socket to match your environment.
The default configuration assumes that NGINX Prometheus Exporter binary is located in
/usr/local/bin/nginx-prometheus-exporter.
The ExecStart directive has the flag --web.systemd-socket which tells the exporter to listen on the socket specified
in the nginx_exporter.socket file.
The ListenStream directive in nginx_exporter.socket specifies the socket to listen on. The default configuration
uses 9113 port, but the address can be written in various formats, for example /run/nginx_exporter.sock. To see the
full list of supported formats, run man systemd.socket.
Installation
- Copy
nginx_exporter.serviceandnginx_exporter.socketto/etc/systemd/system/ - Add a user named
nginx_exporter - Run
systemctl daemon-reload - Run
systemctl start nginx_exporter - Run
systemctl status nginx_exporterto check the status of the service
Verification
- Run
curl http://localhost:9113/metricsto see the metrics exposed by the exporter.