Prometheus监控主机基础指标配置及告警
1、监控主机指标
这是一篇介绍主机使用Prometheus监控CPU、磁盘、内存、负载等基础数据的文章,目前生产可用,使用的是node_exporter-0.18.1版本,操作系统是centos7.X版本,使用之前请修改job="gt-dwz-node-exporter"的值对应自己在Prometheus配置的job名称。
2、Prometheus配置项
在prometheus.yml配置文件中添加如下配置:
############gt-dwz#################
- job_name: "gt-dwz-node-exporter"
static_configs:
- targets: ["10.1.5.123:9100","10.1.5.124:9100","10.1.5.125:9100","10.1.5.126:9100"]
labels:
service: gt-dwz-monitor
1
2
3
4
5
6
3、PromQL判断rules文件
[root@gtcq-gt-monitor-prometheus-01 rules]# more gt-dwz-monitor.rules
groups:
- name: dwz-gt-monitor
rules:
- alert: "node-Agent告警"
expr: up{job="gt-dwz-node-exporter"} == 0
for: 120s
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "Agent告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ $labels.instance }} 已停止采集监控数据 30s!"
description: "{{ $labels.instance }} job {{ $labels.job }} 暴露监控数据已停止."
- alert: "CPU使用率监控"
expr: ceil(100 - sum(increase(node_cpu_seconds_total{job="gt-dwz-node-exporter",mode="idle"}[5m])) by(instance) / sum(increase(node_cpu_seconds_total{job="gt-dwz-node-exporter"}[5m]))
by(instance)*100) > 80
for: 2m
labels:
severity: "重要"
team: bdfb
alert_type: "CPU告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }} CPU使用率过高"
description: "IP:{{ reReplaceAll ":(.*)" "" $labels.instance }}的CPU使用大于80% (当前值: {{ $value }})"
- alert: "磁盘使用率监控"
expr: round((1 - (node_filesystem_avail_bytes{fstype=~"ext3|ext4|xfs|nfs",job="gt-dwz-node-exporter"} / node_filesystem_size_bytes{fstype=~"ext3|ext4|xfs|nfs",job="gt-dwz-node-exporter"
})) * 100) > 80
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "Disk告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }} : {{ $labels.mountpoint }} 分区使用率过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }}的{{ $labels.mountpoint }} 分区使用大于80% (当前值: {{ $value }}%)"
- alert: "内存使用率监控"
expr: ceil( (1 - (node_memory_MemAvailable_bytes{job="gt-dwz-node-exporter"} / (node_memory_MemTotal_bytes{job="gt-dwz-node-exporter"})))* 100 ) > 80
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "MEM告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }}内存使用率过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }}内存使用大于80% (当前值: {{ $value }})"
- alert: "服务器大法宝CPULoad5"
expr: node_load5{job="gt-dwz-node-exporter"} > 100
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "负载告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }}CPU负载过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }} CPU负载load大于100 (当前值: {{ $value }})"
- alert: "服务器文件句柄监控"
expr: node_filefd_allocated{job="gt-dwz-node-exporter"} > 50000
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "文件句柄告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }} 文件句柄使用过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }} 文件句柄使用过高大于50000 (当前值: {{ $value }})"
- alert: "服务器TCP连接数监控"
expr: node_sockstat_TCP_tw{job="gt-dwz-node-exporter"} > 15000
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "TCP连接数告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }} 等待关闭的TCP连接数过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }} 等待关闭的TCP连接数TIME_WAIT过高大于15000 (当前值: {{ $value }})"
- alert: "服务器入口流量监控"
expr: round((sum by (instance) (irate(node_network_receive_bytes_total{job="gt-dwz-node-exporter",device!~"tap.*|veth.*|br.*|docker.*|virbr*|lo*"}[5m])))/1024/1024) > 50
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "流量告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }}监控入口流量过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }} 监控入口流量过高过高大于50MB (告警值: {{ $value }}MB)"
- alert: "服务器出口流量监控"
expr: round((sum by (instance) (irate(node_network_transmit_bytes_total{job="gt-dwz-node-exporter",device!~"tap.*|veth.*|br.*|docker.*|virbr*|lo*"}[5m])))/1024/1024) > 50
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "流量告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }} 监控出口流量过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }} 监控出口流量过高过高大于50MB (告警值: {{ $value }}MB)"
[root@gtcq-gt-monitor-prometheus-01 rules]#
4、测试告警
修改磁盘阈值如下:
- alert: "磁盘使用率监控"
expr: round((1 - (node_filesystem_avail_bytes{fstype=~"ext3|ext4|xfs|nfs",job="gt-dwz-node-exporter"} / node_filesystem_size_bytes{fstype=~"ext3|ext4|xfs|nfs",job="gt-dwz-node-exporter"})) * 100) > 10
for: 2m
labels:
severity: "重要"
team: dwz-gt-monitor
alert_type: "Disk告警"
alert_host: "{{ reReplaceAll ":(.*)" "" $labels.instance }}"
annotations:
summary: "{{ reReplaceAll ":(.*)" "" $labels.instance }} : {{ $labels.mountpoint }} 分区使用率过高"
description: "{{ reReplaceAll ":(.*)" "" $labels.instance }}的{{ $labels.mountpoint }} 分区使用大于10% (当前值: {{ $value }}%)"
决策参考三大运营商将开展全国范围的5G中低频段试验1人民网拟260万入股铁血科技,投资额下调近65事件近日,人民网发布公告称,公司与铁血科技签订新的战略框架协议,铁血科技拟向人民网发行913326股普通股股票,发行价格为人民币2。
县级融媒中心如何建?2018年8月21日至22日,全国宣传思想工作会议在北京召开,会议指出要扎实抓好县级融媒体中心建设,更好引导群众服务群众。这也是继2014年8月18日中央全面深化改革领导小组第四次
市场出清是传统媒体转型和改革的必要前提当前,我国传统媒体正处于转型和改革的关键时期,一些地方对了推进转型,纷纷采取了整合当地传媒资源的做法,如北京市以新京报社为主体,整合了千龙网和北京晨报社天津市整合了天津广播电视台天
决策参考字节跳动以投前估值750亿美元完成PreIPO融资1BCG联合财富发布未来公司50强榜单,21家中企入选事件近日,BCG联合财富杂志,评估了全球最大的1千多家企业,这些企业的入选门槛是年销售额达到100亿美元,或市值达到200亿美
成立大数据管理局是智慧城市建设的有力抓手近期,湖南辽宁海南山东江苏广东等省的机构改革方案已经通过,其中山东福建等省新成立了大数据管理局,再加上广东省等省在省经信委内部设立大数据局,意味着很多省份开始高度重视大数据战略和智
决策参考中国有175家入榜全球创新企业1000强12018全球创新企业1000强公布,中国有175家入榜事件近日,普华永道思略特发布的第14期全球创新1000强报告发现,2018年全球创新1000强的研发支出总额上升了11。4,
新京报转移到以App为中心Netflix宣布三部原创电影先在影院首映1新京报转型,以报纸为中心转移到以App为中心事件近日,新京报正式推出App,新京报将以移动传播视频表达为优先,把移动客户端作为新京报传播主阵地打造,并适时推出新闻业务(政务民生服
真融智能探索才有真未来读迈向智媒体有感传统媒体的融合转型作为一项复杂艰巨的系统性工程,成功标准是既要建设好用户众多的现代传播能力,又要重构商业模式和盈利模式,而要真正实现上述两大目标,必须有智慧地真干。最近读李鹏兄的迈
县级融媒中心建设的1234思路是什么?县级融媒体中心建设的核心是打造现代传播能力和重构商业模式和盈利模式,但说易行难。而要真正建设好用有效的县级融媒体中心,需要采取1234的思路。1大中心建立用户连接更好地引导群众服务
短视频如何变现?移动互联时代的到来,释放了巨大的用户红利,数以亿计的用户成为移动互联用户,在此基础上短视频市场爆发式增长,尤其值得一提的是,经过一段时间的探索实践,短视频的商业变现模式基本成熟,具
决策参考封面新闻拿到三大利好1聚焦资本合作,新华文轩牵手川报集团,助力封面传媒由融媒体向智媒体飞跃事件近日,四川日报报业集团与新华文轩出版传媒股份有限公司与正式签署战略合作关系。新华文轩计划通过资本运作,助力