Promoter is a Webhooks implementation for AlertManager alarm notifications. It currently supports钉钉
and企业微信
, and supports displaying real-time alarm charts in message notifications.
The project is written in Go language and there are many ways to install Promoter.
Directly clone the project and build it manually:
$ git clone https://github.com/cnych/promoter.git
$ cd promoter
$ go build -a -o promoter cmd/promoter/main.go
$ ./promoter --config.file= < your_file >
The Promoter image is uploaded to Docker Hub. You can try using the following command to start the service:
$ docker run --name promoter -d -p 8080:8080 cnych/promoter:main
The following configuration basically covers the configuration used by Promoter:
global :
prometheus_url : http://192.168.31.31:30104
wechat_api_secret : <secret>
wechat_api_corp_id : <secret>
dingtalk_api_token : <secret>
dingtalk_api_secret : <secret>
s3 :
access_key : <secret>
secret_key : <secret>
endpoint : oss-cn-beijing.aliyuncs.com
region : cn-beijing
bucket : <bucket>
receivers :
- name : rcv1
wechat_configs :
- agent_id : <agent_id>
to_user : " @all "
message_type : markdown
message : ' {{ template "wechat.default.message" . }} '
dingtalk_configs :
- message_type : markdown
markdown :
title : ' {{ template "dingtalk.default.title" . }} '
text : ' {{ template "dingtalk.default.content" . }} '
at :
atMobiles : [ "123456" ]
isAtAll : false
Under global, you can configure global attributes, such as enterprise WeChat or DingTalk keys. Under S3, there is an object storage (Alibaba Cloud OSS can also be used) configuration to save the pictures generated by the monitoring icon.
Below receivers
are the configured receivers for various messages. You can configure Enterprise WeChat and DingTalk at the same time in one receiver. It supports two formats: text
and markdown
. name
is very medium. For example, the name here is rcv1
, then the receiver The Webhook address is: http://<promoter-url>/rcv1/send
, which needs to be configured in the AlertManager Webhook.
It should be noted that the Markdown format of Enterprise WeChat does not support direct display of images.
The default template is located in template/default.tmpl
and can be customized according to your own needs:
{{ define "__subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}{{ end }}
{{ define "default.__text_alert_list" }}{{ range . }}
**{{ .Annotations.summary }}**
{{ range .Images }}
![click there get alert image]({{ .Url }})
{{- end }}
**description:**
> {{ .Annotations.description }}
**labels:**
{{ range .Labels.SortedPairs }}{{ if and (ne (.Name) "severity") (ne (.Name) "summary") }}> - {{ .Name }}: {{ .Value | markdown | html }}
{{ end }}{{ end }}
{{ end }}{{ end }}
{{ define "dingtalk.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "dingtalk.default.content" }}
{{ if gt (len .Alerts.Firing) 0 -}}
### {{ .Alerts.Firing | len }} Alerts Firing:
{{ template "default.__text_alert_list" .Alerts.Firing }}
{{ range .AtMobiles }}@{{ . }}{{ end }}
{{- end }}
{{ if gt (len .Alerts.Resolved) 0 -}}
### **{{ .Alerts.Resolved | len }} Alerts Resolved:**
{{ template "default.__text_alert_list" .Alerts.Resolved }}
{{ range .AtMobiles }}@{{ . }}{{ end }}
{{- end }}
{{- end }}
{{ define "wechat.default.message" }}
{{ if gt (len .Alerts.Firing) 0 -}}
### {{ .Alerts.Firing | len }} Alerts Firing:
> {{ template "default.__text_alert_list" .Alerts.Firing }}
{{- end }}
{{ if gt (len .Alerts.Resolved) 0 -}}
### **{{ .Alerts.Resolved | len }} Alerts Resolved:**
{{ template "default.__text_alert_list" .Alerts.Resolved }}
{{- end }}
{{- end }}
{{ define "wechat.default.to_user" }}{{ end }}
{{ define "wechat.default.to_party" }}{{ end }}
{{ define "wechat.default.to_tag" }}{{ end }}
{{ define "wechat.default.agent_id" }}{{ end }}