nginx-exporter安装使用

一、没有vts的启动方式

   #nginx_exporter -telemetry.address=:9113 -nginx.scrape_uri="http://127.0.0.1:10000/nginx_status

   nginx_exporter -telemetry.address=:9113 -nginx.scrape_uri="https://xx.xx.xx.xx:18443" -insecure  #端口9113应该是nginx_exporter监听的端口,prometheus通过9113访问metrics,18443自己可以通过nginx.conf设置其他端口

 

  1.1、修改nginx.conf配置文件

server {
    listen 80;
    ..............................
    location /nginx_status {
            stub_status on;
            access_log off;
            allow 127.0.0.1;
    }
    ................................
    }

  1.2nginx重新加载

    nginx -s reload

  1.3启动nginx-exporter

    nginx_exporter -telemetry.address=:9113 -nginx.scrape_uri="https://xx.xx.xx.xx:18443//nginx_status" -insecure 

 

二、具有vts的启动方式

  nohup   ./${nginx-vts_path}/nginx-vts-exporter    -nginx.scrape_uri=https://xx.xx.xx.xx:18443/status/format/json   #端口18443应该是nginx监听的端口

 

     2.1查看nginx是否有加载模块nginx-module-vts,并拷贝configure arguments:后的字串

         nginx -V​

     2.2备份文件

    解压nginx-module-vts至指定目录,重新编译nginx

    cd  nginx源码

    ./configure   {前面拷贝的configure arguments参数}   --add_module=/nginx-module-vts

 2.3备份原有nginx文件

            cp nginx二进制文件为nginx.bak

      cp nginx源码/objs目录    现有Nginx目录下替换现有的nginx二进制文件

   2.3修改nginx.conf文件

http {
    vhost_traffic_status_zone;  # 添加
    ...
    server {
        ...
        location /status {
            vhost_traffic_status_display;  # 添加
            vhost_traffic_status_display_format html;  # 添加
        }
    }
}

  2.4重新加载nginx

        nginx -s reload

 2.5安装nginx-vts-exporter 

    nohup ./${nginx-vts_path}/nginx-vts-exporter -nginx.scrape_uri=https://xx.xx.xx.xx:18443/status/format/json

 

转载于:https://www.cnblogs.com/kevincaptain/p/10114415.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值