ARM create an alert on multiple resources not working

Hi, there,

The scopes in https://www.terraform.io/docs/providers/azurerm/r/monitor_metric_alert.html is supposed to take a list per doc, but it’s not working….

I can create an alert on one VM without the problem, but I can’t create an alert on multiple VMs or all VMs in resource group of networkeast (resource group level), do you have work around?
I heard that AWZ support resource group level creation, but ARM seems not?


resource “azurerm_monitor_metric_alert” “vm-cpu” {
name =“vm-cpu-metric-alert”
resource_group_name = azurerm_resource_group.jie-test-terraform.name
#scopes = ["/subscriptions/00c2f406-8a8d-4e76-xxxxxxxxx/resourcegroups/networkeast/providers/microsoft.compute/virtualmachines/jie-test01"]
scopes = ["/subscriptions/00c2f406-8a8d-4e76-b898-xxxxxxxxx/resourcegroups/networkeast"]
description = “Action will be triggered when Transactions count is greater than 90.”
severity = “1”
frequency = “PT5M”
window_size = “PT15M” #
criteria {
metric_namespace = “Microsoft.Compute/virtualMachines”
metric_name = “Percentage CPU”
aggregation = “Average”
operator = “GreaterThan”
threshold = 90
}
}

I can’t even list 2 VMs in the scopes, like:
scopes = ["/subscriptions/00c2f406-8a8d-4e76-b898-xxxxxxxx/resourcegroups/networkeast/providers/microsoft.compute/virtualmachines/jie-test01","/subscriptions/00c2f406-8a8d-4e76-b898-xxxxxxx/resourcegroups/networkeast/providers/microsoft.compute/virtualmachines/jie-test02"]

I’m not familiar with the details this resource, but I have a few suggestions that might allow others to help you out here:

  • Can you reformat your message so that the configuration is wrapped in code tags? Clicking the <> button in the toolbar should help.
  • What happens when you try to apply with the configuration containing multiple resource IDs in the scopes list? Can you paste the output of terraform plan or terraform apply?