【问题标题】:The Azure Alerts using webhook to Slack is not working使用 Webhook 到 Slack 的 Azure 警报不起作用
【发布时间】:2020-11-13 02:00:04
【问题描述】:

我正在使用 Azure 警报来使用 webhook。我在操作组中添加了 webhook。我使用的 URL 来自 Slack。

我还添加了通知类型电子邮件。通知电子邮件被触发,但我没有在 Slack 频道中收到任何消息。

我能够使用邮递员将消息推送到 webhook,因此我知道我的 webhook 是正确的。但 Azure 警报无法触发 webhook。我在 Slack 频道中没有收到任何消息。

请帮忙。

【问题讨论】:

    标签: azure notifications alerts


    【解决方案1】:

    Azure Monitor 使用自己的架构定义发送通知。 Slack 无法识别它,因此您无法在频道中看到任何通知。可以创建逻辑应用或 Azure 函数来转换默认架构。

    这里有更多关于它的信息: https://docs.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-common-schema

    【讨论】:

    • 通过门户关闭了“alerts-common-schema”,但它仍然无法正常工作。我使用了 slack webhook。
    【解决方案2】:

    任何想要使用 Slack 和 Azure 警报的人。这似乎工作正常:

    ...
      webhook_receiver {
        name                    = "Slack"
        service_uri             = "https://hooks.slack.com/services/secret"
        use_common_alert_schema = false
      }
    

    然后在定时查询规则alert中:

    ...
      action {
        action_group           = [data.azurerm_monitor_action_group.actiongroup.id]
        email_subject          = "Disk storage at less than 10%"
        custom_webhook_payload = "{ \"text\" : \"Warning: Storage has less than 10% diskspace remaining!\"}"
      }
    

    【讨论】:

      【解决方案3】:

      使用 webhook 时,Slack 需要一个 json 对象。直接从 azure alert 发送时,您会收到错误的请求。

      每个 Slack 频道都有一个电子邮件地址。您可以在 azure alerts 中使用该电子邮件向频道发布消息

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 1970-01-01
      • 2015-10-19
      • 2022-01-01
      • 2022-11-02
      • 1970-01-01
      • 2018-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多