第一步:确定alertmanager的配置文件没有写错

在alertmanager的安装目录中使用下面的命令进行查看

./amtool check-config  配置文件名称 

实际测试

[root@localhost alertmanager]# ./amtool check-config  alertmanager.yml 
Checking 'alertmanager.yml'  SUCCESS
Found:
 - global config
 - route
 - 1 inhibit rules
 - 1 receivers
 - 0 templates

[root@localhost alertmanager]# 

第二步:确定规则的配置文件和模板配置文件是否正确

这些就需要自己去查看了

第三步:确定Prometheus配置文件中的报警地址和规则是否正确

  alertmanagers:
  - static_configs:
    - targets:
       - 192.168.156.133:9093

实际操作


[root@localhost prometheus-2.6.1.linux-amd64]# vim prometheus.yml 
alerting:
# 这个是将当前的Prometheus与alertmanagers关联上
  alertmanagers:
  - static_configs:
    - targets:
       - 192.168.156.133:9093 # alertmanagers的地址 

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
  # 规则的地址
  - "/opt/prometheus/prometheus-2.6.1.linux-amd64/rules/*.rules"	
# 这下面是其他的信息,我删除了
"prometheus.yml" 35L, 1159C 已写入                                                                                     
[root@localhost prometheus-2.6.1.linux-amd64]#

第四步:查看alertmanager里面的配置文件是否正确

比如邮件,

smtp_require_tls: false	

是否使用 tls,根据环境不同,来选择开启和关闭。

  1. 如果提示报错 email.loginAuth failed: 530 Must issue a STARTTLS command first,那么就需要设置为 true。
  2. 如果开启了 tls,提示报错 starttls failed: x509: certificate signed by unknown authority,需要在 email_configs 下配置 insecure_skip_verify: true 来跳过 tls 验证。

其他的配置信息自己查看官方文档或者是其他博客吧

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐