# AlertManager警报通知 E-mail 微信 模板

#AlertManager配置

 #alertmanager.yml

 # 全局配置项
global:
resolve_timeout: 5m #超时,默认5min
#邮箱smtp服务
smtp_smarthost: 'smtp.qq.com:587'
smtp_from: 'report@elven.vip'
smtp_auth_username: 'report@elven.vip'
smtp_auth_password: 'xxx密码'
smtp_hello: 'qq.com'
#smtp_require_tls: false
#wechat
#wechat_api_url: "https://qyapi.weixin.qq.com/cgi-bin/"
wechat_api_corp_id: "wwe518* 企业微信账号唯一ID"
wechat_api_secret: "自定义应用 应用的密钥" # 模板
templates:
- '/alertmanager/*.tmpl' # 路由
route:
group_by: ['alertname'] # 报警分组依据
group_wait: 20s #组等待时间
group_interval: 20s # 发送前等待时间
repeat_interval: 12h #重复周期
receiver: 'email' # 默认警报接收者
#子路由
routes:
- receiver: 'wechat'
match:
severity: test #标签severity为test时满足条件,使用wechat警报 # 警报接收者
receivers:
- name: 'email' #警报名称
email_configs:
- to: '228@elven.vip' # 接收警报的email
html: '{{ template "emai.html" . }}' # 模板
headers: { Subject: " {{ .CommonLabels.instance }} {{ .CommonAnnotations.summary }}" } #标题 - name: 'wechat' #警报名称
wechat_configs:
- send_resolved: true
to_party: '2' #接收部门id
agent_id: '1000002' #应用ID
to_user: ''
to_tag: ''
message: '{{ template "wechat.html" . }}'

send_resolved: true 恢复后通知

to_user: 企业微信用户ID

corp_id: 企业微信账号唯一ID 可以在 我的企业 查看

to_party: 需要发送的组id

agent_id: 应用的 ID,应用管理 --> 打开自定应用查看

api_secret: 应用的密钥

打开企业微信注册 https://work.weixin.qq.com

微信API官方文档 https://work.weixin.qq.com/api/doc#90002/90151/90854


#email模板

vi email.tmpl

{{ define "emai.html" }}
{{ range .Alerts }}
<pre>
实例: {{ .Labels.instance }}
信息: {{ .Annotations.summary }}
详情: {{ .Annotations.description }}
时间: {{ .StartsAt.Format "2006-01-02 15:04:05" }}
</pre>
{{ end }}
{{ end }}

#微信模板

vi wecaht.tmpl

{{ define "wechat.html" }}
{{- if gt (len .Alerts.Firing) 0 -}}{{ range .Alerts }}
@警报
实例: {{ .Labels.instance }}
信息: {{ .Annotations.summary }}
详情: {{ .Annotations.description }}
时间: {{ .StartsAt.Format "2006-01-02 15:04:05" }}
{{ end }}{{ end -}}
{{- if gt (len .Alerts.Resolved) 0 -}}{{ range .Alerts }}
@恢复
实例: {{ .Labels.instance }}
信息: {{ .Annotations.summary }}
时间: {{ .StartsAt.Format "2006-01-02 15:04:05" }}
恢复: {{ .EndsAt.Format "2006-01-02 15:04:05" }}
{{ end }}{{ end -}}
{{- end }}

警报通知内容,根据需求配置,我本人喜欢内容简洁


邮件通知

微信通知

最新文章

  1. design包 TabLayout使用
  2. nginx响应时间监控脚本
  3. NOIP复赛
  4. 【C语言入门教程】4.8 指针数组
  5. js 函数和变量的提升
  6. TCP建立连接、断开连接以及正常报文的报头和报位的大小
  7. webserver 发布问题
  8. A Tour of Go Web servers
  9. Delphi GDI+ Library
  10. MFC和Qt优缺点
  11. 第2章 来点C#的感觉
  12. Laravel项目部署上线(阿里云 Ubuntu 16.04)
  13. layui常见问题记录
  14. dubbo高级配置学习(上)
  15. bokeyuan_python文章爬去入mongodb读取--LOWBIPROGRAMMER
  16. Linux系统下(x64)安装jdk 1.6(jdk-6u45-linux-x64.bin)
  17. Python 中的几种矩阵乘法 np.dot, np.multiply, *【转】
  18. linux自学(三)之开启虚拟机
  19. PHP 中for循环的一个小小改进
  20. svn TortoiseSVN 回滚版本

热门文章

  1. scala学习笔记(8)文件和正则表达式
  2. js验证小数或者整数
  3. axios 文件流下载
  4. Markov Chain Monte Carlo Simulation using C# and MathNet
  5. nohup - 使程序运行时不挂起, 不向 tty 输出信息
  6. Codeforces 907 矩阵编号不相邻构造 团操作状压DFS
  7. bzoj5017 [Snoi2017]炸弹 (线段树优化建图+)tarjan 缩点+拓扑排序
  8. Oracle 9i,10g,11g各自alert日志的位置
  9. heroinfo_set.all 函数
  10. docker for windows 中挂载文件到容器