使用 Webhook 通过 PagerDuty 发送 Azure 服务运行状况警报Send Azure service health alerts with PagerDuty using webhooks

本文演示如何使用 Webhook 通过 PagerDuty 设置 Azure 服务运行状况通知。This article shows you how to set up Azure service health notifications through PagerDuty using a webhook. 使用 PagerDuty 的自定义 Azure 集成类型,可以轻松地将服务运行状况警报添加到新的或现有的 PagerDuty 服务。By using PagerDuty's custom Azure integration type, you can effortlessly add Service Health alerts to your new or existing PagerDuty services.

在 PagerDuty 中创建服务运行状况集成 URLCreating a service health integration URL in PagerDuty

  1. 请确保已注册并登录到 PagerDuty 帐户。Make sure you have signed up for and are signed into your PagerDuty account.

  2. 在 PagerDuty 中导航到“服务” 部分。Navigate to the Services section in PagerDuty.

    PagerDuty 中的“服务”部分

  3. 选择“添加新服务” 或打开已设置的现有服务。Select Add New Service or open an existing service you have set up.

  4. 在“集成设置” 中,选择以下项:In the Integration Settings, select the following:

    a.a. 集成类型:AzureIntegration Type: Azure

    b.b. 集成名称:<Name>Integration Name: <Name>

    PagerDuty 中的“集成设置”

  5. 填写任何其他必填字段,然后选择“添加” 。Fill out any other required fields and select Add.

  6. 打开此新集成,复制并保存“集成 URL” 。Open this new integration and copy and save the Integration URL.

    PagerDuty 中的“集成 URL”

在 Azure 门户中使用 PagerDuty 创建警报Create an alert using PagerDuty in the Azure portal

对于新操作组:For a new action group:

  1. 执行使用 Azure 门户为新操作组创建有关服务运行状况通知的警报中的步骤 1 到步骤 8。Follow steps 1 through 8 in Create an alert on a service health notification for a new action group by using the Azure portal.

  2. 在“操作” 列表中定义:Define in the list of Actions:

    a.a. 操作类型: WebhookAction Type: Webhook

    b.b. 详细信息: 前面保存的 PagerDuty 集成 URLDetails: The PagerDuty Integration URL you previously saved.

    c.c. 名称: Webhook 的名称、别名或标识符。Name: Webhook's name, alias, or identifier.

  3. 警报创建完成后,选择“保存” 。Select Save when done to create the alert.

对于现有操作组:For an existing action group:

  1. Azure 门户中,选择“监视” 。In the Azure portal, select Monitor.

  2. 在“设置” 部分中,选择“操作组” 。In the Settings section, select Action groups.

  3. 找到要编辑的操作组并选择它。Find and select the action group you want to edit.

  4. 添加到“操作” 列表:Add to the list of Actions:

    a.a. 操作类型: WebhookAction Type: Webhook

    b.b. 详细信息: 前面保存的 PagerDuty 集成 URLDetails: The PagerDuty Integration URL you previously saved.

    c.c. 名称: Webhook 的名称、别名或标识符。Name: Webhook's name, alias, or identifier.

  5. 操作组更新完成后,选择“保存” 。Select Save when done to update the action group.

通过 HTTP POST 请求测试 Webhook 集成Testing your webhook integration via an HTTP POST request

  1. 创建要发送的服务运行状况有效负载。Create the service health payload you want to send. 可以在 Azure 活动日志警报的 Webhook 中找到示例服务运行状况 Webhook 有效负载。You can find an example service health webhook payload at Webhooks for Azure activity log alerts.

  2. 按如下所示创建 HTTP POST 请求:Create an HTTP POST request as follows:

    POST        https://events.pagerduty.com/integration/<IntegrationKey>/enqueue
    
    HEADERS     Content-Type: application/json
    
    BODY        <service health payload>
    
  3. 应会收到 202 Accepted 并显示包含“事件 ID”的消息。You should receive a 202 Accepted with a message containing your "event ID."

  4. 转到 PagerDuty,确认集成已设置成功。Go to PagerDuty to confirm that your integration was set up successfully.

后续步骤Next steps