Last active
September 2, 2025 04:44
-
-
Save UlricQin/0b9bccd9d9b01265a2e969f3a5d14f7f to your computer and use it in GitHub Desktop.
夜莺监控钉钉通知的消息模板。使用机器人 markdown 的消息格式
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #### {{if $event.IsRecovered}}<font color="#008800">💚{{$event.RuleName}}</font>{{else}}<font color="#FF0000">💔{{$event.RuleName}}</font>{{end}} | |
| --- | |
| {{$time_duration := sub now.Unix $event.FirstTriggerTime }}{{if $event.IsRecovered}}{{$time_duration = sub $event.LastEvalTime $event.FirstTriggerTime }}{{end}} | |
| **💨告警级别**: {{$event.Severity}}级 | |
| {{if $event.RuleNote}} | |
| **📜规则备注**: {{$event.RuleNote}} | |
| {{end}} | |
| {{if not $event.IsRecovered}} | |
| **⏱️当次触发时间**: {{timeformat $event.TriggerTime}} | |
| **🧭告警持续时长**: {{humanizeDurationInterface $time_duration}} | |
| **🔴当次触发时值**: {{$event.TriggerValue}} | |
| {{else}} | |
| {{- if $event.AnnotationsJSON.recovery_value}} | |
| **🟢恢复时值**: {{formatDecimal $event.AnnotationsJSON.recovery_value 4}} | |
| {{- end}} | |
| **⏱️恢复时间**: {{timeformat $event.LastEvalTime}} | |
| **🧭告警持续时长**: {{humanizeDurationInterface $time_duration}} | |
| {{end}} | |
| {{if $event.TagsMap}} | |
| **🏷️事件标签**: | |
| {{- range $key, $val := $event.TagsMap}} | |
| {{ if ne $key "rulename" }}- {{$key}}: {{$val}}{{ end }} | |
| {{- end}} | |
| {{end}} | |
| {{if $event.AnnotationsJSON}} | |
| **📚附加信息**: | |
| {{- range $key, $val := $event.AnnotationsJSON}} | |
| - {{$key}}: {{$val}} | |
| {{- end}} | |
| {{end}} | |
| {{$domain := "http://localhost:17000" }} | |
| [事件详情]({{$domain}}/share/alert-his-events/{{$event.Id}}) | [屏蔽1小时]({{$domain}}/alert-mutes/add?__event_id={{$event.Id}}){{if eq $event.Cate "prometheus"}} | [查看曲线]({{$domain}}/metric/explorer?__event_id={{$event.Id}}&mode=graph){{end}} | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
注意,上面的内容最下面故意加了两个空行。否则就会和 at 的消息混在一行了。最终效果如下: