hey there
am struggling with a problem with Terraform. any help is appreciated!
what i want to do is set an alert on a number of VMs in a resource group in Azure. I can do this via the portal
my code is:
resource “azurerm_monitor_metric_alert” “devcpualert”{
name = “Dev Environments - CPU alert”
resource_group_name = azurerm_resource_group.rg.name
scopes = ["/subscriptions/ea7bc135-xxxx-xxxx-xxxx-3a104eb84a98/resourceGroups/RG1", “/subscriptions/ea7bc135-xxxx-xxxx-xxxx-3a104eb84a98/resourceGroups/RG2”]
description = “”
enabled = true
severity = 3
tags = {}
target_resource_type = Microsoft.Compute/virtualMachines
criteria {
metric_namespace = "microsoft.compute/virtualmachines"
metric_name = "Percentage CPU"
aggregation = "Average"
operator = "GreaterThan"
threshold = 99.0
}
action {
action_group_id= "/subscriptions/ea7bc135-bf0a-470c-a0c4-3a104eb84a98/resourceGroups/RGxxxx/providers/microsoft.insights/actionGroups/123devops"
}
}
can run Terraform plan ok - its only when i run Terraform apply i get this:
Error: Error creating or updating metric alert “Dev Environments - CPU alert” (resource group “xxxx”): insights.MetricAlertsCertsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 – Original Error: autorest/azure: Service returned an error. Status=400 Code=“BadRequest” Message="Alerts are currently not supported at resource group level for . Activity ID
how can i do this with Terraform.
I need to be able to do this using RG not subscriptions etc.
Thanks a mil.
Neil.