一、步骤1:新建通知内容模板
1. 登录 日志服务控制台。
2. 在左侧导航栏中,选择监控告警 > 通知内容模板,进入通知内容模板管理页面。
3. 单击新建,在自定义回调标签中,根据需要对接的渠道,填写如下信息并保存。
PagerDutySlackMicrosoft TeamsJira Service ManagementGoogle Chat
注意:说明:
告警触发
·请求头
Accept: application/json
Content-Type: application/json
·请求内容
{ "payload": { "summary": "{{escape .Alarm}}", "timestamp": "{{fromUnixTime .NotifyTimeUnix}}", "severity": "{{if eq .Level "Critical"}}critical{{else if eq .Level "Warn"}}warning{{else if eq .Level "Info"}}info{{end}}", "source": "Tencent Cloud Log Service", "custom_details": { "Alarm Policy": "{{escape .Alarm}}", "Trigger Condition": "{{escape .Condition}}", "Current Data": "{{escape .TriggerParams}}", "Additional Message": "{{escape .Message}}", "Multidimensional Analysis": "{{escape .AnalysisResultFormat}}" } }, "routing_key": "R03ECCMUCxxxxxxxxxxxNGFE87CT", "dedup_key": "{{.RecordGroupId}}", "event_action": "trigger", "client": "{{escape .Topic}}", "client_url": "{{.QueryUrl}}", "links": [ { "href": "{{.DetailUrl}}", "text": "Alert Detail" } ]}
告警恢复
·请求头
Accept: application/json
Content-Type: application/json
·请求内容
{ "payload": { "summary": "{{escape .Alarm}}", "timestamp": "{{fromUnixTime .NotifyTimeUnix}}", "severity": "{{if eq .Level "Critical"}}critical{{else if eq .Level "Warn"}}warning{{else if eq .Level "Info"}}info{{end}}", "source": "Tencent Cloud Log Service" }, "routing_key": "R03ECCMUCxxxxxxxxxxxNGFE87CT", "dedup_key": "{{.RecordGroupId}}", "event_action": "resolve"}
告警触发
·请求头
Content-Type: application/x-www-form-urlencoded
·请求内容
{{- define "subTemplate" -}}Alarm triggered for the log service of account {{.UIN}} ({{.Nickname}}):• Alarm Policy: {{.Alarm}}• Alarm Level: {{.Level}}• Monitoring Object: {{.Topic}}• Trigger Condition: {{.Condition}}• Current Data: {{.TriggerParams}}• Trigger Time: {{.StartTime}}{{- if (gt .Duration 0)}}• Duration: {{.Duration}} minutes{{- end}}• Additional Message: {{.Message}}• Multidimensional Analysis:“`{{.AnalysisResultFormat}}“`<{{.DetailUrl}}|DetailedReport> <{{.QueryUrl}}|QueryData>{{if .CanSilent}} <{{.DetailUrl}}|ClaimAlarm> <{{.SilentUrl}}|SilenceAlarm>{{end}}{{- end -}}payload={"username": "CLS Alert","icon_emoji": ":rotating_light:","blocks": [{"type":"header","text":{"type":"plain_text","text":":rotating_light:Alarm:{{escape .Alarm}}","emoji":true}},{"type": "section","text": {"type": "mrkdwn","text": "{{escape (substr (renderTemplate "subTemplate") 0 3500)}}"}}]}
告警恢复
·请求头
Content-Type: application/x-www-form-urlencoded
·请求内容
{{- define "subTemplate" -}} A CLS alarm was resolved under your account (ID: {{.UIN}}; name: {{.Nickname}}):• Alarm Policy: {{.Alarm}}• Alarm Level: {{.Level}}• Monitoring Object: {{.Topic}}• Trigger Condition: {{.Condition}}• Trigger Time: {{.StartTime}}• Resolved Time: {{.NotifyTime}}• Duration: {{.Duration}} minutes"{{- end -}}payload={"username": "CLS Alert","icon_emoji": ":green_circle:","blocks": [{"type":"header","text":{"type":"plain_text","text":":large_green_circle:Resolved:{{escape .Alarm}}","emoji":true}},{"type": "section","text": {"type": "mrkdwn","text": "{{escape (substr (renderTemplate "subTemplate") 0 3500)}}"}}]}
告警触发
·请求头
Content-Type: application/json
·请求内容
{{- define "subTemplate" -}}**Alarm triggered for the log service of account {{.UIN}} ({{.Nickname}}):**- Alarm Policy: {{.Alarm}}- Alarm Level: {{.Level}}- Monitoring Object: {{.Topic}}- Trigger Condition: {{.Condition}}- Current Data: {{.TriggerParams}}- Trigger Time: {{.StartTime}}{{- if (gt .Duration 0)}}- Duration: {{.Duration}} minutes{{- end}}- Additional Message: {{.Message}}{{- range $key,$value := .AnalysisResult}}**{{$key}}**{{$value}}{{- end}}{{- end -}}{ "type": "message", "attachments": [{ "contentType": "application/vnd.microsoft.card.adaptive", "content": { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.3", "msteams": {"width": "Full"}, "body": [ { "type": "TextBlock", "text": "Alarm:{{escape .Alarm}}", "wrap": true, "color": "{{if eq .Level "Critical"}}attention{{else if eq .Level "Warn"}}warning{{else if eq .Level "Info"}}accent{{end}}", "size": "Large" }, { "type": "TextBlock", "text": "{{- escape (substr (renderTemplate "subTemplate") 0 3500)}}", "wrap": true }, { "type": "ActionSet", "actions": [{"type":"Action.OpenUrl","title":"DetailedReport","url":"{{.DetailUrl}}"},{"type":"Action.OpenUrl","title":"QueryData","url":"{{.QueryUrl}}"}{{if.CanSilent}},{"type":"Action.OpenUrl","title":"ClaimAlarm","url":"{{.DetailUrl}}"},{"type":"Action.OpenUrl","title":"SilenceAlarm","url":"{{.SilentUrl}}"}{{end}}] }] } }]}
告警恢复
·请求头
Content-Type: application/json
·请求内容
{{- define "subTemplate" -}}**A CLS alarm was resolved under your account (ID: {{.UIN}}; name: {{.Nickname}}):**- Alarm Policy: {{.Alarm}}- Alarm Level: {{.Level}}- Monitoring Object: {{.Topic}}- Trigger Condition: {{.Condition}}- Trigger Time: {{.StartTime}}- Resolved Time: {{.NotifyTime}}- Duration: {{.Duration}} minutes"{{- end -}}{ "type": "message", "attachments": [{ "contentType": "application/vnd.microsoft.card.adaptive", "content": { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.3", "msteams": {"width": "Full"}, "body": [ { "type": "TextBlock", "text": "Resolved:{{escape .Alarm}}", "wrap": true, "color": "good", "size": "Large" }, { "type": "TextBlock", "text": "{{- escape (substr (renderTemplate "subTemplate") 0 3500)}}", "wrap": true }] } }]}
注意:说明:
告警触发
·请求头
Accept: application/json
Content-Type: application/json
Authorization: Basic YjdiYjI5MWXXXXXXXXXXXXXXXXXdhNDUyYjVmYjQw
·请求内容
{{- define "subTemplate" -}}Current Data:{{.TriggerParams}}Additional Message:{{.Message}}{{.AnalysisResultFormat}}Detail Report:{{.DetailUrl}}{{- end -}}{ "message": "{{escape .Alarm}}", "alias": "{{.RecordGroupId}}", "description": "Alarm Policy:{{escape .Alarm}}\\nTrigger Condition:{{escape .Condition}}", "entity": "{{escape .Topic}}", "source": "Tencent Cloud Log Service", "priority": "{{if eq .Level "Critical"}}P1{{else if eq .Level "Warn"}}P2{{else if eq .Level "Info"}}P5{{end}}", "note": "{{escape (substr (renderTemplate "subTemplate") 0 3500)}}"}
告警恢复
·请求头
Accept: application/json
Content-Type: application/json
Authorization: Basic YjdiYjI5MWXXXXXXXXXXXXXXXXXdhNDUyYjVmYjQw
·请求内容
{{- define "subTemplate" -}}Alarm was resolvedTrigger Time:{{.StartTime}}Resolved Time:{{.NotifyTime}}Duration: {{.Duration}} minutes"{{- end -}}{ "message": "{{escape .Alarm}}", "alias": "{{.RecordGroupId}}", "description": "Alarm Policy:{{escape .Alarm}}\\nTrigger Condition:{{escape .Condition}}", "entity": "{{escape .Topic}}", "source": "Tencent Cloud Log Service", "priority": "{{if eq .Level "Critical"}}P1{{else if eq .Level "Warn"}}P2{{else if eq .Level "Info"}}P5{{end}}", "note": "{{escape (substr (renderTemplate "subTemplate") 0 3500)}}"}
注意:中国大陆地域(北京、广州、上海、重庆等)不支持直接对接 Google Chat。
告警触发
·请求头
Content-Type: application/json; charset=UTF-8
·请求内容
{{- define "subTemplate" -}}*Alarm triggered for the log service of account {{.UIN}} ({{.Nickname}})** Alarm Policy: {{.Alarm}}* Alarm Level: {{.Level}}* Monitoring Object: {{.Topic}}* Trigger Condition: {{.Condition}}* Current Data: {{.TriggerParams}}* Trigger Time: {{.StartTime}}{{- if (gt .Duration 0)}}* Duration: {{.Duration}} minutes{{- end}}* Additional Message: {{.Message}}* Multidimensional Analysis:“`{{.AnalysisResultFormat}}“`<{{.DetailUrl}}|DetailedReport> <{{.QueryUrl}}|QueryData>{{if .CanSilent}} <{{.DetailUrl}}|ClaimAlarm> <{{.SilentUrl}}|SilenceAlarm>{{end}}{{- end -}}{"text": "{{escape (substr (renderTemplate "subTemplate") 0 3500)}}"}
告警恢复
·请求头
Content-Type: application/json; charset=UTF-8
·请求内容
{{- define "subTemplate" -}}*A CLS alarm was resolved under your account (ID: {{.UIN}}; name: {{.Nickname}})** Alarm Policy: {{.Alarm}}* Alarm Level: {{.Level}}* Monitoring Object: {{.Topic}}* Trigger Condition: {{.Condition}}* Trigger Time: {{.StartTime}}* Resolved Time: {{.NotifyTime}}* Duration: {{.Duration}} minutes"{{- end -}}{"text": "{{escape (substr (renderTemplate "subTemplate") 0 3500)}}"}
二、步骤2:新建通知渠道组
1. 在左侧导航栏中,选择监控告警 > 通知渠道组,进入通知渠道组管理页面。
2. 单击新建,在通知规则中单击添加规则,在设置通知渠道中填写如下信息并保存:
·渠道类型:自定义接口回调
·Webhook地址:
·PagerDuty:Add Integrations to an Existing Service 步骤中的 Integration URL。
·Slack:CLS 通过 Incoming Webhooks 与 Slack 对接,如当前无合适的 Incoming Webhooks,请执行 Sending messages using incoming webhooks,创建 Incoming Webhook,获取其中的 Webhook URL。
·Microsoft Teams:CLS 通过 Workflows 与 Teams 对接,请执行 Create incoming webhooks with Workflows for Microsoft Teams,以模板方式创建 workflow,获取其中的 URL。模板请选择 Post to a channel when a webhook request is received。
·Jira Service Management:https://api.atlassian.com/jsm/ops/integration/v2/alerts。
·Google Chat:CLS 通过 webhook 与 Google Chat 对接,如当前无合适的 webhook,请执行 Register the incoming webhook,创建 Webhook,获取其中的 webhook URL。
·请求方法:POST
·内容模板:选择 步骤1 新建的通知内容模板。
注意:说明:
注意:详细的配置说明可参考 管理通知渠道组。
三、步骤3:在告警策略中选择通知渠道组
1. 在左侧导航栏中,选择监控告警 > 告警策略,进入告警策略管理页面。
2. 单击新建,开始配置告警策略,详细的配置说明可参考 配置告警策略。其中关联通知渠道组时选择 步骤2 新建的通知渠道组。