tencent cloud

日志服务

动态与公告
产品动态
公告
新手指引
产品简介
产品概述
产品优势
地域和访问域名
规格与限制
基本概念
购买指南
计费概述
产品定价
按量计费(后付费)
欠费说明
清理日志服务资源
成本优化
常见问题
快速入门
一分钟入门指南
入门指南
使用 Demo 日志快速体验 CLS
操作指南
资源管理
权限管理
日志采集
指标采集
日志存储
指标存储
检索分析(日志主题)
检索分析(指标主题)
仪表盘
数据处理
投递与消费
监控告警
云产品中心
DataSight 独立控制台
历史文档
实践教程
日志采集
检索分析
仪表盘
监控告警
投递和消费
成本优化
开发者指南
通过 iframe 内嵌 CLS(旧方案)
通过 Grafana 使用 CLS
API 文档
History
Introduction
API Category
Making API Requests
Topic Management APIs
Log Set Management APIs
Index APIs
Topic Partition APIs
Machine Group APIs
Collection Configuration APIs
Log APIs
Metric APIs
Alarm Policy APIs
Data Processing APIs
Kafka Protocol Consumption APIs
CKafka Shipping Task APIs
Kafka Data Subscription APIs
COS Shipping Task APIs
SCF Delivery Task APIs
Scheduled SQL Analysis APIs
COS Data Import Task APIs
Data Types
Error Codes
常见问题
健康监测问题解释
采集相关
检索分析相关
其他问题
服务等级协议
CLS 政策
隐私协议
数据处理和安全协议
联系我们
词汇表
文档日志服务实践教程监控告警告警对接 PagerDuty/Slack/Microsoft Teams

告警对接 PagerDuty/Slack/Microsoft Teams

PDF
聚焦模式
字号
最后更新时间: 2025-06-20 10:15:25

简介

告警可通过自定义回调的方式对接 PagerDuty、Slack、Microsoft Teams、Jira Service Management、Google Chat,便于统一接收告警通知。

配置步骤

步骤1:新建通知内容模板

2. 在左侧导航栏中,选择监控告警 > 通知内容模板,进入通知内容模板管理页面。
3. 单击新建,在自定义回调标签中,根据需要对接的渠道,填写如下信息并保存。
PagerDuty
Slack
Microsoft Teams
Jira Service Management
Google Chat
说明:
CLS 通过 Events API V2与 PagerDuty 对接,如果当前 Service 未添加 Events API V2 Integration,请执行 Add Integrations to an Existing Service
请替换以下请求内容中的routing_key为 PagerDuty 中的 Integration Key。
请同时记录 PagerDuty 中的 Integration URL,便于后续步骤使用。
告警触发
请求头
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
}]
}
}]
}
说明:
CLS 通过 API Integration 与 JSM(Jira Service Management) 对接,如果当前未添加 API Integration,请执行 Add a global integration。添加完成后启用该 Integration,并获取其中的 API key。
请替换以下请求头中的Authorization为 JSM 中的 API Key,格式为Basic+空格+Base64 编码后的 API Key
告警触发
请求头
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 resolved
Trigger 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 新建的通知渠道组。




帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈