prometheus监控传统环境监控(二)nginx监控

编程入门 行业动态 更新时间:2024-10-25 08:23:07

prometheus监控<a href=https://www.elefans.com/category/jswz/34/1769179.html style=传统环境监控(二)nginx监控"/>

prometheus监控传统环境监控(二)nginx监控

prometheus监控nginx

github地址:

环境:

        组件nginx-prometheus-exporter部署位置:192.168.0.39

        nginx服务器:172.30.0.10

通过组件nginx-prometheus-exporter进行监控

nginx需要安装有with-http_stub_status_module模块,一般高版本的nginx会自带这个模块

检查

# nginx -V 2>&1 | grep -o with-http_stub_status_module
with-http_stub_status_module

nginx增加配置

创建一个server,监听38888端口,开启监控,只允许192.168.0.39访问

server {listen  38888;location /nginx_status {stub_status on;allow 192.168.0.39;  #only allow requests from localhostdeny all;   #deny all other hosts}}

测试一下

172.30.0.10就是刚刚那台nginx主机

# curl http://172.30.0.10:38868/nginx_statusActive connections: 12189 
server accepts handled requests195544839 195544839 1147258694 
Reading: 0 Writing: 63 Waiting: 12018

创建启动监控组件

需要指定被监控主机(我这里没试过能不能添加多个被监控主机,有测试过的小伙伴可以留言)

我启动了多个组件

端口:9117 自定义的

docker run -d \
--name nginx_exporter_qalb_10 \
-m 1g \
--restart=always \
--restart=on-failure:5 \
-p 9117:9113 \
nginx/nginx-prometheus-exporter:0.10.0 \
-nginx.scrape-uri http://172.30.0.10:38888/nginx_status

prometheus集成nginx-prometheus-exporter组件

prometheus.yml

添加

# nginx- job_name: nginx-qalb-10static_configs:- targets: ['192.168.0.10:9117']labels:instance: nginx-qalb-10有多个组件就再加一个,注意端口别冲突- job_name: nginx-qalb-11static_configs:- targets: ['192.168.0.10:9118']labels:instance: nginx-qalb-11

重启prometheus容器

添加告警规则

nginx_export-alert-rules.yaml

groups:- name: nginx状态-监控告警rules:- alert: nginx状态expr: nginx_up == 0for: 1slabels:serverity: warningstatus: 非常严重annotations:summary: "{{$labels.instance}}:nginx服务停止"description: "nginx服务down"

重启prometheus容器生效

grafana图形码:12708

NGINX exporter dashboard for Grafana | Grafana Labs

上一篇:基础环境搭建

prometheus监控传统环境监控(一)_我的喵叫初六的博客-CSDN博客

下一篇:URL监控

prometheus监控传统环境监控(三)_我的喵叫初六的博客-CSDN博客

更多推荐

prometheus监控传统环境监控(二)nginx监控

本文发布于:2024-03-13 23:11:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1735101.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:传统   环境   prometheus   nginx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!