NGINX Prometheus Exporter
NGINX Prometheus exporter 可以使用 Prometheus 监控 NGINX 或 NGINX Plus。
https://github.com/nginxinc/nginx-prometheus-exporter
概述
NGINX通过stub_status 页面公开了一些指标。NGINX Plus通过API和监控仪表板提供了一组更丰富的指标。NGINX Prometheus 导出器从单个 NGINX 或 NGINX Plus 获取指标,将指标转换为适当的 Prometheus 指标类型,最后通过 HTTP 服务器公开它们以供 Prometheus收集。
注意。不是nginx-prometheus-exporter守护进程。要将导出器作为系统服务(守护进程)运行,请相应地配置 Linux 服务器的初始化系统(例如 systemd 或 Upstart)。或者,您可以在 Docker 容器中运行导出器。
二进制文件
要导出 NGINX 指标,请运行:
$ nginx-prometheus-exporter -nginx.scrape-uri=http://<nginx>:8080/stub_status
<nginx>
IP 地址/DNS 名称在哪里,通过它可以使用 NGINX。
要导出 NGINX Plus 指标:
$ nginx-prometheus-exporter -nginx.plus -nginx.scrape-uri=http://<nginx-plus>:8080/api
<nginx-plus>
IP 地址/DNS 名称在哪里,通过它可以使用 NGINX Plus。
要使用 unix 域套接字导出和抓取 NGINX 指标,请运行:
$ nginx-prometheus-exporter -nginx.scrape-uri=unix:<nginx>:/stub_status -web.listen-address=unix:/path/to/socket.sock
<nginx>
unix 域套接字的路径在哪里,NGINX 存根状态可通过该路径获得。
用法
命令行参数
Usage of ./nginx-prometheus-exporter:
-nginx.plus
Start the exporter for NGINX Plus. By default, the exporter is started for NGINX. The default value can be overwritten by NGINX_PLUS environment variable.
-nginx.retries int
A number of retries the exporter will make on start to connect to the NGINX stub_status page/NGINX Plus API before exiting with an error. The default value can be overwritten by NGINX_RETRIES environment variable.
-nginx.retry-interval duration
An interval between retries to connect to the NGINX stub_status page/NGINX Plus API on start. The default value can be overwritten by NGINX_RETRY_INTERVAL environment variable. (default 5s)
-nginx.scrape-uri string
A URI or unix domain socket path for scraping NGINX or NGINX Plus metrics.
For NGINX, the stub_status page must be available through the URI. For NGINX Plus -- the API. The default value can be overwritten by SCRAPE_URI environment variable. (default "http://127.0.0.1:8080/stub_status")
-nginx.ssl-ca-cert string
Path to the PEM encoded CA certificate file used to validate the servers SSL certificate. The default value can be overwritten by SSL_CA_CERT environment variable.
-nginx.ssl-client-cert string
Path to the PEM encoded client certificate file to use when connecting to the server. The default value can be overwritten by SSL_CLIENT_CERT environment variable.
-nginx.ssl-client-key string
Path to the PEM encoded client certificate key file to use when connecting to the server. The default value can be overwritten by SSL_CLIENT_KEY environment variable.
-nginx.ssl-verify
Perform SSL certificate verification. The default value can be overwritten by SSL_VERIFY environment variable. (default true)
-nginx.timeout duration
A timeout for scraping metrics from NGINX or NGINX Plus. The default value can be overwritten by TIMEOUT environment variable. (default 5s)
-prometheus.const-labels value
A comma separated list of constant labels that will be used in every metric. Format is label1=value1,label2=value2... The default value can be overwritten by CONST_LABELS environment variable.
-web.listen-address string
An address or unix domain socket path to listen on for web interface and telemetry. The default value can be overwritten by LISTEN_ADDRESS environment variable. (default ":9113")
-web.telemetry-path string
A path under which to expose metrics. The default value can be overwritten by TELEMETRY_PATH environment variable. (default "/metrics")
-web.secured-metrics
Expose metrics using https. The default value can be overwritten by SECURED_METRICS variable. (default false)
-web.ssl-server-cert string
Path to the PEM encoded certificate for the nginx-exporter metrics server(when web.secured-metrics=true). The default value can be overwritten by SSL_SERVER_CERT variable.
-web.ssl-server-key string
Path to the PEM encoded key for the nginx-exporter metrics server (when web.secured-metrics=true). The default value can be overwritten by SSL_SERVER_KEY variable.
-version
Display the NGINX exporter version. (default false)
作者:Jeebiz 创建时间:2023-02-28 19:49
最后编辑:Jeebiz 更新时间:2024-01-24 21:48
最后编辑:Jeebiz 更新时间:2024-01-24 21:48