nginx_exporter使用

官方网站 https://github.com/nginxinc/nginx-prometheus-exporter

下载二进制文件 nginx-prometheus-exporter

wget https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v0.11.0/nginx-prometheus-exporter_0.11.0_linux_amd64.tar.gz #下载二进制文件
tar zxf nginx-prometheus-exporter_0.11.0_linux_amd64.tar.gz -C /opt  #解压
vim /etc/nginx/nginx.conf #配置文件开放stub_status页面,在http块内
server {
        listen       8080;
        server_name  localhost;
 location /stub_status {
     stub_status;
 }
}
nginx -t
nginx -s reload
nohup  ./nginx-prometheus-exporter & #后台运行,查看9113端口
在prometheus配置文件内添加
  - job_name: "nginx"
    static_configs:
     - targets: ["192.168.48.139:9113"]

重启可以查看到nginx的exporter

如果自定义nginx的页面,并且修改exporter使用的端口,使用下面这条命令启动

nohup  ./nginx-prometheus-exporter -nginx.scrape-uri=http://192.168.48.139:8087/stub_status -web.listen-address=:9189 &