You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure智能警报规则自定义Webhook Payload不生效问题排查

问题根源

Azure智能警报(如Smart Detection类规则)与常规指标/日志搜索警报的自定义Payload配置逻辑存在差异:你当前在智能警报规则中配置的properties.actionGroups.customWebhookPayload是常规警报专属的配置字段,智能警报规则并不识别该路径的配置,因此触发时不会将自定义内容注入Webhook请求体。

解决方法

针对启用通用警报架构的智能警报,需通过以下两种方式之一配置自定义属性:

方式一:在动作组的Webhook中全局配置(适用于所有关联该动作组的警报)

在Terraform的azurerm_monitor_action_group资源里,为Webhook接收器添加custom_properties块,所有关联该动作组的警报(包括智能警报)触发时,都会将这些自定义属性带入通用警报架构的customProperties节点中。

示例Terraform代码:

resource "azurerm_monitor_action_group" "example" {
  name                = "example-action-group"
  resource_group_name = azurerm_resource_group.example.name
  short_name          = "ex-ag"

  webhook_receiver {
    name                    = "example-webhook"
    service_uri             = "https://your-webhook-endpoint.com"
    use_common_alert_schema = true # 已启用通用警报架构

    # 全局自定义属性
    custom_properties = {
      env       = "production"
      alert_tag = "smart-alert"
      team      = "devops"
    }
  }
}

方式二:针对单个智能警报规则配置专属自定义属性

如果需要仅为某条智能警报添加独有的自定义属性,需在智能警报规则的properties层级直接配置customProperties字段(而非actionGroups子节点)。

示例Terraform代码(以Smart Detection的应用洞察智能警报为例):

resource "azurerm_monitor_smart_detector_alert_rule" "example" {
  name                = "example-smart-alert"
  resource_group_name = azurerm_resource_group.example.name
  scope_resource_id   = azurerm_application_insights.example.id
  detector_type       = "FailureAnomalies"
  severity            = "Sev3"

  action_group {
    action_group_id = azurerm_monitor_action_group.example.id
  }

  # 智能警报专属自定义属性
  properties = {
    customProperties = {
      alert_specific_key = "smart-alert-only-value"
      priority           = "medium"
    }
  }
}
验证方法

触发智能警报后,查看Webhook请求体的customProperties节点,自定义属性会直接嵌套在此节点下,格式如下:

{
  "schemaId": "azureMonitorCommonAlertSchema",
  "data": {
    "customProperties": {
      "env": "production",
      "alert_tag": "smart-alert",
      "alert_specific_key": "smart-alert-only-value"
    },
    // 其他通用警报字段...
  }
}

内容的提问来源于stack exchange,提问作者jsfr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 03:39:50