Skip to content

Commit ba0dd5d

Browse files
authored
Merge pull request #78 from flashcatcloud/lm_test
slack app default template
2 parents 99e9fee + fd242c1 commit ba0dd5d

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

flashduty/en/1. On-call/4. Configure On-call/4.7 Templates.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,18 @@ As shown below:
433433
You need to configure `Integration Center-Instant Message-Slack` integration first to send message cards. If custom content is not set, the system default template will be used, rendering only common label information:
434434
435435
```go
436-
{{if .Description}}*description* :{{toHtml .Labels.body_text .Description}}{{end}}
437-
{{if .Labels.resource}}*resource* : {{toHtml (joinAlertLabels . "resource" ", ")}}{{end}}
436+
{{if .Labels.body_text}}{{.Labels.body_text}}{{else if .Description}}{{.Description}}{{end}}
437+
{{if .Labels.resource}}*resource* : {{(joinAlertLabels . "resource" ", ")}}{{end}}
438438
{{range $k, $v := .Labels}}
439-
{{if not (in $k "resource" "body_text")}}*{{$k}}* : {{toHtml $v}}{{end}}{{end}}
439+
{{if not (in $k "resource" "body_text" "body_text_with_table")}}*{{$k}}* : {{$v}}{{end}}{{end}}
440+
{{ $root := . }}
441+
{{ range $i, $v := .Images }}
442+
{{ $imageURL := imageSrcToURL $root $v.Src }}
443+
{{ if $imageURL }}
444+
---
445+
![{{$v.Alt}}]({{$imageURL}})
446+
{{ end }}
447+
{{ end }}
440448
```
441449
442450
As shown below:

flashduty/zh/1. On-call/3. 配置管理/4.7 配置通知模板.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,18 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi
435435
您需要预先配置 `集成中心-即时消息- Slack` 集成,才能发送消息卡片。如果不设置自定义内容,将采用系统默认模板,仅渲染常见标签信息:
436436

437437
```go
438-
{{if .Description}}*description* :{{toHtml .Labels.body_text .Description}}{{end}}
439-
{{if .Labels.resource}}*resource* : {{toHtml (joinAlertLabels . "resource" ", ")}}{{end}}
438+
{{if .Labels.body_text}}{{.Labels.body_text}}{{else if .Description}}{{.Description}}{{end}}
439+
{{if .Labels.resource}}*resource* : {{(joinAlertLabels . "resource" ", ")}}{{end}}
440440
{{range $k, $v := .Labels}}
441-
{{if not (in $k "resource" "body_text")}}*{{$k}}* : {{toHtml $v}}{{end}}{{end}}
441+
{{if not (in $k "resource" "body_text" "body_text_with_table")}}*{{$k}}* : {{$v}}{{end}}{{end}}
442+
{{ $root := . }}
443+
{{ range $i, $v := .Images }}
444+
{{ $imageURL := imageSrcToURL $root $v.Src }}
445+
{{ if $imageURL }}
446+
---
447+
![{{$v.Alt}}]({{$imageURL}})
448+
{{ end }}
449+
{{ end }}
442450
```
443451

444452

0 commit comments

Comments
 (0)