钉钉prometheus模板

42次阅读

共计 2610 个字符,预计需要花费 7 分钟才能阅读完成。

{{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 "__alertmanagerURL"}}{{.ExternalURL}}/#/alerts?receiver={{.Receiver}}{{end}}

{{define "__text_alert_list"}}{{range .}}
**Labels**
{{range .Labels.SortedPairs}}> - {{.Name}}: {{.Value | markdown | html}}
{{end}}
**Annotations**
{{range .Annotations.SortedPairs}}> - {{.Name}}: {{.Value | markdown | html}}
{{end}}
**Source:** [{{.GeneratorURL}}]({{.GeneratorURL}})
{{end}}{{end}}

{{define "default.__text_alert_list"}}{{range .}}
---
** 告警级别:** {{.Labels.severity | upper}}

** 运营团队:** {{.Labels.team | upper}}

** 触发时间:** {{dateInZone "2006.01.02 15:04:05" (.StartsAt) "Asia/Shanghai" }}

** 事件信息:** 
{{range .Annotations.SortedPairs}}> - {{.Name}}: {{.Value | markdown | html}}


{{end}}

** 事件标签:**
{{range .Labels.SortedPairs}}{{if and (ne (.Name) "severity") (ne (.Name) "summary") (ne (.Name) "team") }}> - {{.Name}}: {{.Value | markdown | html}}
{{end}}{{end}}
{{end}}
{{end}}
{{define "default.__text_alertresovle_list"}}{{range .}}
---
** 告警级别:** {{.Labels.severity | upper}}

** 运营团队:** {{.Labels.team | upper}}

** 触发时间:** {{dateInZone "2006.01.02 15:04:05" (.StartsAt) "Asia/Shanghai" }}

** 结束时间:** {{dateInZone "2006.01.02 15:04:05" (.EndsAt) "Asia/Shanghai" }}

** 事件信息:**
{{range .Annotations.SortedPairs}}> - {{.Name}}: {{.Value | markdown | html}}


{{end}}

** 事件标签:**
{{range .Labels.SortedPairs}}{{if and (ne (.Name) "severity") (ne (.Name) "summary") (ne (.Name) "team") }}> - {{.Name}}: {{.Value | markdown | html}}
{{end}}{{end}}
{{end}}
{{end}}

{{/* Default */}}
{{define "default.title"}}{{template "__subject" .}}{{end}}
{{define "default.content"}}#### \[{{.Status | toUpper}}{{if eq .Status "firing"}}:{{.Alerts.Firing | len}}{{end}}\] **[{{index .GroupLabels "alertname"}}]({{template "__alertmanagerURL" .}})**
{{if gt (len .Alerts.Firing) 0 -}}

![警报 图标](https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3626076420,1196179712&fm=15&gp=0.jpg)
**==== 侦测到故障 ====**
{{template "default.__text_alert_list" .Alerts.Firing}}


{{- end}}

{{if gt (len .Alerts.Resolved) 0 -}}
{{template "default.__text_alertresovle_list" .Alerts.Resolved}}


{{- end}}
{{- end}}

{{/* Legacy */}}
{{define "legacy.title"}}{{template "__subject" .}}{{end}}
{{define "legacy.content"}}#### \[{{.Status | toUpper}}{{if eq .Status "firing"}}:{{.Alerts.Firing | len}}{{end}}\] **[{{index .GroupLabels "alertname"}}]({{template "__alertmanagerURL" .}})**
{{template "__text_alert_list" .Alerts.Firing}}
{{- end}}

{{/* Following names for compatibility */}}
{{define "ding.link.title"}}{{template "default.title" .}}{{end}}
{{define "ding.link.content"}}{{template "default.content" .}}{{end}}

正文完
 0