prometheus使用 (十七) alertmanager特性--静默

这个其实没啥说的,就是让告警静音,prometheus称这种警报静音为"silence"

比如我们有个业务要维护了,它一定会告警,那么我们可以设置一个时间段之后再告警

1. 页面静默

#我这里停止一台主机的node-exporter
systemctl stop node-exporter

默认是静默2小时,看自己的使用情况。 之前出现过1天上万条告警,这样一来告警就没有意义了

 

2. 命令行静默

我们先手动将页面的静音取消

案例

#创建目录
mkdir /root/.config/amtool/ -p

#添加地址文件
cat > /root/.config/amtool/config.yml <<EOF
alertmanager.url: "http://192.168.1.20:9093"
author: sre@example.com
comment_required: true
EOF


#添加静音
amtool silence add --comment "hello world" --duration "2h" alertname="node-up" instance="192.168.1.20:9100" job="node" severity="1" team="node"



#可以带多个标签来精准匹配
--comment "hello world"    #说明
--duration "2h"      #静音时间
 alertname="node-up" instance="192.168.1.20:9100" job="node" severity="1" team="node"
               #该告警的的标签

返回

b067b3d9-a3b7-4eaf-9cfc-243234aa13fd

常用命令

1. 查看已有的静音

amtool silence query

返回

ID                                    Matchers                                                                    Ends At                  Created By       Comment      
b067b3d9-a3b7-4eaf-9cfc-243234aa13fd  alertname=node-up instance=192.168.1.20:9100 job=node severity=1 team=node  2021-04-09 11:46:47 UTC  sre@example.com  hello world  

2.指定silence过期

amtool silence expire b067b3d9-a3b7-4eaf-9cfc-243234aa13fd
#告警就又被启动了

3.使用正则创建silence

amtool silence add --comment "App1 maintenance" alertname=~'.+'

帮助命令

amtool silence --help

 

一、prometheus简介 Prometheus是一个开源的系统监控和告警系统,现在已经加入到CNCF基金会,成为继k8s之后第二个在CNCF维护管理的项目,在kubernetes容器管理系统中,通常会搭配prometheus进行监控,prometheus支持多种exporter采集数据,还支持通过pushgateway进行数据上报,Prometheus再性能上可支撑上万台规模的集群。 二、prometheus架构图 三、prometheus组件介绍 1.Prometheus Server: 用于收集和存储时间序列数据。 2.Client Library: 客户端库,检测应用程序代码,当Prometheus抓取实例的HTTP端点时,客户端库会将所有跟踪的metrics指标的当前状态发送到prometheus server端。 3.Exporters: prometheus支持多种exporter,通过exporter可以采集metrics数据,然后发送到prometheus server端 4.Alertmanager: 从 Prometheus server 端接收到 alerts 后,会进行去重,分组,并路由到相应的接收方,发出报警,常见的接收方式有:电子邮件,微信,钉钉, slack等。 5.Grafana:监控仪表盘 6.pushgateway: 各个目标主机可上报数据到pushgatewy,然后prometheus server统一从pushgateway拉取数据。 四、课程亮点 五、效果图展示 六、讲师简介 先超(lucky):高级运维工程师、资深DevOps工程师,在互联网上市公司拥有多年一线运维经验,主导过亿级pv项目的架构设计和运维工作 主要研究方向: 1.云计算方向:容器 (kubernetes、docker),虚拟化(kvm、Vmware vSphere),微服务(istio),PaaS(openshift),IaaS(openstack)等2.系统/运维方向:linux系统下的常用组件(nginx,tomcat,elasticsearch,zookeeper,kafka等),DevOps(Jenkins+gitlab+sonarqube+nexus+k8s),CI/CD,监控(zabbix、prometheus、falcon)等 七、课程大纲
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值