AlertManager Eメールアラート通知のマイクロレターテンプレート

#のAlertManager Eメールアラート通知のマイクロレターテンプレート

#AlertManager設定

 #alertmanager.yml

 # 全局配置项
global:
  resolve_timeout: 5m #超时,默认5min
  #邮箱smtp服务
  smtp_smarthost: 'smtp.qq.com:587'
  smtp_from: '[email protected]'
  smtp_auth_username: '[email protected]'
  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: '[email protected]'  # 接收警报的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:真の復帰通知
#のto_user:ビジネスマイクロチャネルのユーザーIDの
#はcorp_id:ビジネスマイクロチャネルはユニークなIDが私のビジネスの中で見ることができるアカウント
#1 to_party:グループIDを送信する必要がある
#のAGENT_ID:アプリケーションID、アプリケーション管理- >から開きます与えられたアプリケーションビュー
#1 api_secretを:主要なアプリケーション

登録された公開書簡#マイクロ企業https://work.weixin.qq.com
#マイクロチャンネル公式APIドキュメントhttps://work.weixin.qq.com/api/doc#90002/90151/90854


#emailテンプレート

#マイクロ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 }}

#マイクロレターテンプレート

#我々は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 }}

#アラート通知内容は、需要の構成に、私は個人的に簡潔好みます


#メール通知
Eメール

#マイクロチャネル通知
微信

おすすめ

転載: www.cnblogs.com/elvi/p/11444278.html
おすすめ