# 集成钉钉：基于Webhook的扩展

在 Alertmanager 中可以使用如下配置定义基于 webhook 的告警接收器 receiver，一个 receiver 可以对应一组 webhook 配置。

```yaml
name: <string>
webhook_configs:
  [ - <webhook_config>, ... ]
```

每一项 webhook\_config 的具体配置格式如下：

```yaml
# Whether or not to notify about resolved alerts.
[ send_resolved: <boolean> | default = true ]

# The endpoint to send HTTP POST requests to.
url: <string>

# The HTTP client's configuration.
[ http_config: <http_config> | default = global.http_config ]
```

* **send\_resolved** 用于指定是否在告警消除时发送回执消息。
* **url** 则是用于接收 webhook 请求的地址。
* **http\_configs** 则是在需要对请求进行 SSL 配置时使用。

当用户定义 webhook 用于接收告警信息后，当告警被触发时，Alertmanager 会按照以下格式向这些 url 地址发送 HTTP Post 请求，请求内容如下：

```json
{
  "version": "4",
  // key identifying the group of alerts (e.g. to deduplicate)
  "groupKey": <string>,    
  "status": "<resolved|firing>",
  "receiver": <string>,
  "groupLabels": <object>,
  "commonLabels": <object>,
  "commonAnnotations": <object>,
  "externalURL": <string>,  // backlink to the Alertmanager.
  "alerts": [
    {
      "labels": <object>,
      "annotations": <object>,
      "startsAt": "<rfc3339>",
      "endsAt": "<rfc3339>"
    }
  ]
}
```
