Azure 警报邮件正文中的失败 API 名称

问题描述 投票:0回答:1

我们在 Azure API 管理上部署了多个 API,我们在 AppInsights 中创建了警报,当检测到失败的 API 时会触发警报。

但是触发的邮件只有失败API的计数信息。我们特别需要 API 名称和有关失败 API 的更多详细信息,例如警报邮件本身中的请求正文/响应正文/API 路径等

我想这可以通过 custom webhook 来实现,但是我找不到任何关于失败的 API 名称和其他详细信息可以从 Alert payload 中获取并可以在自定义 payload 中使用的适当文档。

任何指导 w.r.t.自定义负载示例将非常有帮助。

azure azure-application-insights azure-api-management azure-alerts azure-webhooks
1个回答
0
投票

使用自定义日志查询、操作组和逻辑应用程序,您可以从 API 管理中获取失败的 Api 名称。以下是我遵循并能够在邮件中获取 Api 名称的步骤。

  • 我在 Api 管理上部署的 api 很少。
  • 为 Api 管理配置的应用程序洞察力。
  • 创建如下所示的警报规则, enter image description here
    requests
    | where success == false
    | summarize by operation_Name

enter image description here

  • 在操作选项卡中,添加了一个将触发逻辑应用程序并创建规则的操作组。

  • logic app的设计器如下图, enter image description here

  • 在邮件正文中,发送触发器正文。这将包括有关触发警报的详细信息。

  • 在 Azure app insights 中运行查询时的搜索结果是,

    // Failed operations 
    // Calculate how many times operations failed, and how many users were impacted. 
    // To create an alert for this query, click '+ New alert rule'
    requests
    | where success == false
    | summarize by operation_Name

enter image description here

  • 一旦触发警报,邮件将发送如下所示, enter image description here
  • 如上所示,您将在邮件中获得链接,单击它后,您将能够看到如下所示的带有 api 名称的结果, enter image description here
© www.soinside.com 2019 - 2024. All rights reserved.