Custom webhook payloads for Smart Alerts with Common Alert Schema

Jens 0 Reputation points
2025-01-03T11:24:26.8966667+00:00

I'm trying to define an alert rule for a Smart Alert, where the trigger should be an action group with a webhook using the Common Alert Schema. I need to include some custom properties to the webhook as well.

I'm currently defining the alert rule using terraform, and the definition looks something like this:

resource "azurerm_monitor_smart_detector_alert_rule" "MemoryLeakDetector" {
  enabled             = true
  name                = "MemoryLeakDetector"
  resource_group_name = var.resource_group_name
  severity            = "Sev3"
  scope_resource_ids  = [var.scope_resource_id]
  frequency           = "P1D"
  detector_type       = "MemoryLeakDetector"
  action_group {
    ids = [var.oncall_action_group_id]
    webhook_payload = jsonencode({
      CustomProperty1 = "FooBar"
    })
  }
}

For the custom payload that ends up in the JSON definition of the rule under properties.actionGroups.customWebhookPayload which is different from when I define regular metric/log search rules. Those also have the action group part of terraform looking slightly different, like this instead:

action {
  action_group_id = var.oncall_action_group_id
  webhook_properties = {
    CustomProperty1 = "FooBar"
  }
}

And then it instead ends up in the JSON definition in properties.actions.customProperties.

For the regular metric/log search rules, when they are triggered the custom payload comes through and is present as described by the common alert schema. However, for the Smart Alert rules, the custom payload isn't present in the body of the call to the webhook at all.

All rules use the same action group with the same webhook, and all of them use the common alert schema.

Is there something wrong with my assumptions here, and how can I get the custom payload onto the body of the call when using smart alert rules?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,402 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.