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

本文介绍如何使用 Webhook,通过 OpsGenie 设置 Azure 服务运行状况警报。This article shows you how to set up Azure service health alerts with OpsGenie using a webhook. 可以通过 OpsGenie 的 Azure 服务运行状况集成,将 Azure 服务运行状况警报转发到 OpsGenie。By using OpsGenie's Azure Service Health Integration, you can forward Azure Service Health alerts to OpsGenie. OpsGenie 根据值勤计划来确定要通知的适当人员,使用电子邮件、短信 (SMS)、电话、iOS 和 Android 推送通知以及升级警报向他们发出通知,直到这些人员确认收到警报或将其关闭。OpsGenie can determine the right people to notify based on on-call schedules, using email, text messages (SMS), phone calls, iOS & Android push notifications, and escalating alerts until the alert is acknowledged or closed.

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

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

  2. 在 OpsGenie 中导航到“集成”部分。 Navigate to the Integrations section in OpsGenie.

    OpsGenie 中的“集成”部分

  3. 选择“Azure 服务运行状况” 集成按钮。Select the Azure Service Health integration button.

    OpsGenie 中的“Azure 服务运行状况按钮”

  4. 为警报命名,并指定“分配到团队”字段。 Name your alert and specify the Assigned to Team field.

  5. 填写其他字段,例如“收件人”、“启用”、“禁止显示通知”。 Fill out the other fields like Recipients, Enabled, and Suppress Notifications.

  6. 复制并保存“集成 URL”,其中应该已经包含追加到末尾的 apiKeyCopy and save the Integration URL, which should already contain your apiKey appended to the end.

    OpsGenie 中的“集成 URL”

  7. 选择“保存集成” Select Save Integration

在 Azure 门户中使用 OpsGenie 创建警报Create an alert using OpsGenie 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. 详细信息: 前面保存的 OpsGenie 集成 URL 。Details: The OpsGenie 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. 详细信息: 前面保存的 OpsGenie 集成 URL 。Details: The OpsGenie 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://api.opsgenie.com/v1/json/azureservicehealth?apiKey=<APIKEY>
    
    HEADERS     Content-Type: application/json
    
    BODY        <service health payload>
    
  3. 此时会收到 200 OK 响应,其中包含状态消息“成功”。You should receive a 200 OK response with the message of status "successful."

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

后续步骤Next steps