调用CreateOrUpdateWebhookContact接口创建或修改Webhook告警联系人。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String CreateOrUpdateWebhookContact

系统规定参数。取值:CreateOrUpdateWebhookContact

WebhookId Long 123

Webhook告警联系人ID。

  • 不填代表创建新的Webhook告警联系人。
  • 填写代表修改指定Webhook告警联系人信息。
WebhookName String Webhook告警

Webhook告警联系人名称。

Method String Post

HTTP请求方法。

  • Post
  • Get
Url String https://oapi.dingtalk.com/robot/send?access_token=e1a049121******

Method的请求方法URL。

BizHeaders String [{"Content-Type":"application/json;charset=utf-8"}]

HTTP请求头。

BizParams String [{"content":"mike"}]

HTTP请求参数。

Body String { "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "告警时间":"{{ .startTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }

告警触发时发送的通知模板,当Method设置为Post时必填,可使用$content占位符输出通知内容,不可超过500个字符。更多信息,请参见通知模板的变量说明

RecoverBody String { "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "恢复时间":"{{ .endTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }

告警恢复时发送的通知模板,当Method设置为Post时必填,可使用$content占位符输出通知内容,不可超过500个字符。更多信息,请参见通知模板的变量说明

返回数据

名称 类型 示例值 描述
RequestId String 16AF921B-8187-489F-9913-43C808B4****

请求ID。

WebhookContact Object

返回的WebhookContact对象。

WebhookId Float 123

Webhook告警联系人ID。

WebhookName String Webhook告警

Webhook告警联系人名称。

Webhook Object

返回的Webhook对象。

Method String Post

HTTP请求方法。

  • Post
  • Get
Url String https://oapi.dingtalk.com/robot/send?access_token=e1a049121******

请求方法URL。

BizHeaders String [{"Content-Type":"application/json;charset=utf-8"}]

HTTP请求头。

BizParams String [{"content":"mike"}]

HTTP请求参数。

Body String { "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "告警时间":"{{ .startTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }

告警通知模板。

RecoverBody String { "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "恢复时间":"{{ .endTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }

告警恢复模板。

示例

请求示例

http(s)://[Endpoint]/?Action=CreateOrUpdateWebhookContact
&WebhookId=123
&WebhookName=Webhook告警
&Method=Post
&Url=https://oapi.dingtalk.com/robot/send?access_token=e1a049121******
&BizHeaders=[{"Content-Type":"application/json;charset=utf-8"}]
&BizParams=[{"content":"mike"}]
&Body={ "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "告警时间":"{{ .startTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }
&RecoverBody={ "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "恢复时间":"{{ .endTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }
&公共请求参数

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateOrUpdateWebhookContactResponse>
    <RequestId>16AF921B-8187-489F-9913-43C808B4****</RequestId>
    <WebhookContact>
        <WebhookId>123</WebhookId>
        <WebhookName>Webhook告警</WebhookName>
        <Webhook>
            <Method>Post</Method>
            <Url>https://oapi.dingtalk.com/robot/send?access_token=e1a049121******</Url>
            <BizHeaders>[{"Content-Type":"application/json;charset=utf-8"}]</BizHeaders>
            <BizParams>[{"content":"mike"}]</BizParams>
            <Body>{ "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "告警时间":"{{ .startTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }</Body>
            <RecoverBody>{ "告警名称":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "集群名称":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "应用名称":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "通知策略":"{{ .dispatchRuleName }}", "恢复时间":"{{ .endTime }}", "告警内容":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }</RecoverBody>
        </Webhook>
    </WebhookContact>
</CreateOrUpdateWebhookContactResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "16AF921B-8187-489F-9913-43C808B4****",
  "WebhookContact" : {
    "WebhookId" : 123,
    "WebhookName" : "Webhook告警",
    "Webhook" : {
      "Method" : "Post",
      "Url" : "https://oapi.dingtalk.com/robot/send?access_token=e1a049121******",
      "BizHeaders" : "[{\"Content-Type\":\"application/json;charset=utf-8\"}]",
      "BizParams" : "[{\"content\":\"mike\"}]",
      "Body" : "{ \"告警名称\":\"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\", \"集群名称\":\"{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\", \"应用名称\":\"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\", \"通知策略\":\"{{ .dispatchRuleName }}\", \"告警时间\":\"{{ .startTime }}\", \"告警内容\":\"{{ for .alerts }} {{ .annotations.message }} {{ end }}\" }",
      "RecoverBody" : "{ \"告警名称\":\"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\", \"集群名称\":\"{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\", \"应用名称\":\"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\", \"通知策略\":\"{{ .dispatchRuleName }}\", \"恢复时间\":\"{{ .endTime }}\", \"告警内容\":\"{{ for .alerts }} {{ .annotations.message }} {{ end }}\" }"
    }
  }
}