加载中...

prometheus配置nginx监控


本篇主要介绍通过nginx-vts来获取nginx监控情况 1.nginx编译安装需要添加vts模块

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --add-module=../nginx-module-vts/ --with-http_ssl_module
make && make install

nginx -V查看模块是否添加成功

2.nginx配置文件添加配置

http下配置这两个参数
vhost_traffic_status_zone;
vhost_traffic_status_filter_by_host on;

server段
server {
        listen 8089;
        server_name localhost;
        root html;
        index index.html index.php;
    location /status {
                        vhost_traffic_status_display;
                        vhost_traffic_status_display_format html;
      }
}

3.配置完成重启服务 通过ip+prot/status访问

4.nginx-vts-exporter下载并配置

wget -c https://github.com/hnlq715/nginx-vts-exporter/releases/download/v0.9.1/nginx-vts-exporter-0.9.1.linux-amd64.tar.gz
mkdir /usr/local/nginx-vts-exporter
tar xf nginx-vts-exporter-0.9.1.linux-amd64.tar.gz -C /usr/local/nginx-vts-exporter
nohup ./nginx-vts-exporter -nginx.scrape_timeout 10 -nginx.scrape_uri http://172.19.0.3:8082/status/format/json &

5.promethues添加配置

- job_name: 'Nginx'
    static_configs:
    - targets:
      - '106.75.x.x:9913'

6.grafana导入模板并查看

导入nginx模板

结果展示

[[[1] ] ] https://www.huhuhahei.cn/usr/uploads/2021/08/644249520.png

[[[2] ] ] http://www.huhuhahei.cn/usr/uploads/2021/08/462020058.png

[[[3] ] ] https://www.huhuhahei.cn/usr/uploads/2021/08/501805390.png

[[[4] ] ] https://www.huhuhahei.cn/usr/uploads/2021/08/3857789207.png


文章作者: huhuhahei
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 huhuhahei !
评论
  目录