nginx_exporter的安装

1.首先本地需要安装好prometheus已经nginx,注意nginx在编译的时候需要带with-http_stub_status_module模块

#检查nginx是否安装nginx模块
./nginx -V 2>&1 |grep -o with_http_stub_status_module
如果有输出则证明安装了,没有的话就重新编译一下nginx

2.修改nginx的配置文件

#新增location
location /nginx_status {
    stub_status on;
    }
#新增后重新加载nginx配置
/usr/local/nginx/sbin/nginx -s reload

3.安装 并启动nginx_prometheus插件

#安装
tar -zxf nginx-prometheus-exporter_0.10.0_linux_amd64.tar.gz -C /usr/local/
#启动
nohup ./nginx-prometheus-exporter -nginx.scrape-uri=http://127.0.0.1:80/nginx_status &

4.添加prometheus监听配置文件

- targets: ["10.50.161.161:9113"]   #9113是nginx_prometheus的服务端口
  labels:
    instance: "10.50.161.161"
    env: "cdrb-nginx"

5.重启prometheus

posted @ 2022-04-11 10:46  caibutou  阅读(1070)  评论(0编辑  收藏  举报