预览消息模板邮件格式
功能介绍
该接口用于预览通知模板邮件格式
URI
POST /v2/{project_id}/{domain_id}/lts/events/notification/templates/view
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
project_id | 是 | String | 项目ID,获取方式请参见:获取项目ID,获取账号ID,日志组ID、日志流ID 最小长度:32 最大长度:32 |
domain_id | 是 | String | 账号ID,获取方式请参见:获取项目ID,获取账号ID,日志组ID、日志流ID 最小长度:32 最大长度:32 |
请求参数
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
X-Auth-Token | 是 | String | 从IAM服务获取的用户Token,获取方式请参见:获取用户Token 最小长度:1000 最大长度:2000 |
Content-Type | 是 | String | 该字段填为:application/json;charset=UTF-8。 最小长度:30 最大长度:30 |
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
templates | 是 | String | 邮件模板内容 最小长度:2 最大长度:1024 |
language | 是 | String | 语言类型,例如en-us |
source | 是 | String | 来源,只能填LTS 最小长度:3 最大长度:3 |
subject | 否 | String | 额外渲染该字段内容作为消息模板的大标题 |
响应参数
状态码:200
参数 | 参数类型 | 描述 |
|---|---|---|
template | String | 为一个html文本,需要进行相应的解析后展示 |
subject | String | 返回的html文本最上方会有解析该字段内容后用于展示的大标题 |
状态码:500
参数 | 参数类型 | 描述 |
|---|---|---|
error_code | String | 错误码 |
error_msg | String | 错误内容 |
请求示例
预览消息模板邮件格式
POST https://{endpoint}/v2/{project_id}/{domain_id}/lts/events/notification/templates/view
{
"templates" : "告警级别:${event_severity};\n发生时间:${starts_at};\n告警源:$event.metadata.resource_provider;\n资源类型:$event.metadata.resource_type;\n资源标识:${resources};\n统计类型:关键词统计;\n表达式:$event.annotations.condition_expression;\n当前值: $event.annotations.current_value;\n统计周期:$event.annotations.frequency;\n查询时间:$event.annotations.results[0].time;\n查询日志:$event.annotations.results[0].raw_results;",
"language" : "en-us",
"source" : "LTS",
"subject" : "${region_name}[${event_severity}_${event_type}_${clear_type}]于${starts_at}时间发生告警"
} 响应示例
状态码:200
请求响应成功。
{
"template" : "<style> span { display: inline-block; float: left; font-size: 14px; } b { display: inline-block; float: left; color: #252B3A; font-size: 14px }</style><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"font-family:Helvetica,Arial,PingFangSC-Regular,Hiragino Sans GB;border-spacing:0px 14px;font-size:14px;padding-left: 30px;line-height:25px;\"> <thead> <tr style=\"font-size:14px;\"> <td colspan=\"2\" style=\"line-height:28px;color:#6e6e6e;font-size:14px\"> <b>Dear </b> <b>users</b> <b> , </b> </td> </tr> </thead> <tr> <td colspan=\"2\"> <span>1 notifications has been </span> <span>add</span> <span> in region </span> <b>xx</b> <span> based on </span> <span>alarm rule </span> <b>action_rule</b> <span>. For more information, go to the LTS console.</span> <br> <br> </td> </tr> <tr style=\"font-size:14px;\"> <td colspan=\"2\"> <p style=\"margin-top: -26px;margin-bottom: -20px;\"> <br> <span style=\"color:#252B3A;line-height:24px\">Here are the details.</span> </p> </td> </tr> <td><div>告警级别:Major;<br>发生时间:2022-03-21 18:23:20 GMT+08:00;<br>告警源:NA;<br>资源类型:NA;<br>资源标识:CCE;<br>统计类型:关键词统计;<br>表达式:NA;<br>当前值: NA;<br>统计周期:NA;<br>查询时间:NA;<br>查询日志:NA;<br><div/></td> </table>",
"subject" : "[Major_alarm_add]于2022-03-21 18:23:20 GMT+08:00时间发生告警"
} 状态码:500
domain_id填写错误时返回报错
{
"error_code" : "LTS.2019",
"error_msg" : "Failed to preview notification template."
} 状态码
状态码 | 描述 |
|---|---|
200 | 请求响应成功。 |
500 | domain_id填写错误时返回报错 |
错误码
请参见错误码。

