modify dingtalk markdown
This commit is contained in:
parent
acc797666d
commit
8570c2d287
|
@ -86,7 +86,13 @@ class Sender(object):
|
|||
|
||||
@classmethod
|
||||
def send_dingtalk(cls, payload):
|
||||
users = payload.get('event').get("notify_users_obj")
|
||||
event = payload.get('event')
|
||||
users = event.get("notify_users_obj")
|
||||
|
||||
rule_name = event.get("rule_name")
|
||||
event_state = "Triggered"
|
||||
if event.get("is_recovered"):
|
||||
event_state = "Recovered"
|
||||
|
||||
tokens = {}
|
||||
phones = {}
|
||||
|
@ -107,8 +113,8 @@ class Sender(object):
|
|||
body = {
|
||||
"msgtype": "markdown",
|
||||
"markdown": {
|
||||
"title": "n9e notice",
|
||||
"text": payload.get('tpls').get("dingtalk.tpl", "dingtalk.tpl not found")
|
||||
"title": "{} - {}".format(event_state, rule_name),
|
||||
"text": payload.get('tpls').get("dingtalk.tpl", "dingtalk.tpl not found") + ' '.join(["@"+i for i in phones.keys()])
|
||||
},
|
||||
"at": {
|
||||
"atMobiles": phones.keys(),
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
- **级别状态**: {{if .IsRecovered}}<font color="green">S{{.Severity}} Recovered</font>{{else}}<font color="#00ff00">S{{.Severity}} Triggered</font>{{end}}
|
||||
- **规则标题**: {{.RuleName}}{{if .RuleNote}}
|
||||
- **规则备注**: {{.RuleNote}}{{end}}
|
||||
- **监控指标**: {{.TagsJSON}}
|
||||
- {{if .IsRecovered}}**恢复时间**:{{timeformat .LastEvalTime}}{{else}}**触发时间**: {{timeformat .TriggerTime}}
|
||||
**触发时值**: {{.TriggerValue}}{{end}}
|
||||
- **发送时间**: {{timestamp}}
|
||||
### {{if .IsRecovered}}<font color="#008800">S{{.Severity}} - Recovered - {{.RuleName}}</font>{{else}}<font color="#FF0000">S{{.Severity}} - Triggered - {{.RuleName}}</font>{{end}}
|
||||
|
||||
> - **规则标题**: {{.RuleName}}{{if .RuleNote}}
|
||||
> - **规则备注**: {{.RuleNote}}{{end}}
|
||||
> - **监控指标**: {{.TagsJSON}}
|
||||
> - {{if .IsRecovered}}**恢复时间**:{{timeformat .LastEvalTime}}{{else}}**触发时间**: {{timeformat .TriggerTime}}
|
||||
> - **触发时值**: {{.TriggerValue}}{{end}}
|
||||
> - **发送时间**: {{timestamp}}
|
Loading…
Reference in New Issue