配置

vim /root/alertmanager/config.yml

global:
  smtp_smarthost: 'smtp.139.com:465'   # 139发件服务器 ,同理也可设置qq企业,163邮箱等
  smtp_from: '135XXX651@139.com'
  smtp_auth_username: '139XXX7651@139.com'
  smtp_auth_password: 'XX自己的密码XXX'

route:
  receiver: team-test-mails 
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 1m
  repeat_interval: 2m
  - match:
      severity: error
   
receivers:
  - name: 'team-test-mails'
    email_configs:

    - to: '13475639563@163.com'

docker search alertmanager

docker pull docker.io/prom/alertmanager:latest


docker run -d -p 9093:9093 -v /root/alertmanager/config.yml:/etc/alertmanager/config.yml --name alertmanager docker.io/prom/alertmanager:latest

验证设置是否成功,也就是说怎么让警告发送给你的邮箱,需要结合prometheus的/etc/prometheus-rules/alertting.rules设置,点击打开链接

可以举个例子,这是关于监控kubernetes的报警设置,当然,关于其他内容的详细设置日后会做详解

groups:
- name: example-rules
  interval: 30s # defaults to global interval
  rules:
  - alert: Node Down
    expr: up{job="kubernetes-nodes"} == 0
    labels:
      severity: error
    annotations:
      miqTarget: "ContainerNode"
      severity: "HIGH"
      message: "{{$labels.instance}} is down"
  - alert: "Too Many Pods"
    expr: sum(kubelet_running_pod_count) > 50
    labels:
      severity: error
    annotations:
      miqTarget: "ExtManagementSystem"  
      severity: "ERROR"
      url: "https://www.example.com/too_many_pods_fixing_instructions"

      message: "Too many running pods"




Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐