question

ChrisPeacock-1515 avatar image
0 Votes"
ChrisPeacock-1515 asked olufemiaMSFT edited

Azure Monitor - Terraform Alerts not firing unless portal created alert created

I've created an Azure Monitor alert using the following Terraform code:

resource "azurerm_monitor_metric_alert" "azureMonitorMetricAlert1VmCpuCritical1" { name = "VM CPU Critical" resource_group_name = var.resourceGroup1Name scopes = [var.logAnalytics1Id] target_resource_type = "" description = "Action will be triggered when Virtual Machine CPU is greater than 95%" frequency = "PT1M" window_size = "PT5M" criteria { metric_namespace = "Microsoft.OperationalInsights/workspaces" metric_name = "Average_% Processor Time" aggregation = "Average" operator = "GreaterThan" threshold = 95 dimension { name = "Computer" operator = "Include" values = ["*"] } } action { action_group_id = azurerm_monitor_action_group.azureMonitorActionGroup1.id } tags = var.tags }

However, this doesn't fire any alerts (email/SMS) unless I manually create an alert, even the same alert and metrics etc, in the portal. It doesn't matter which order; I create the above alert in TF, then manually create another alert; or I manually create an alert then run the TF code. But regardless, without the manually created alert the TF alerts don't fire.

Has anyone else seen this issue?

I've compared the data from the PS cmdlet: Get-AzMetricAlertRuleV2 with both created alerts and they're identical.

Any thoughts?



azure-monitor
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @ChrisPeacock-1515, If i understand correctly, the TF alert doesn't fire when the alert conditions are met/true?
If this is the case then we may need deeper debugging to get to the root-cause. We have 2 options here:

  1. If you have a support plan linked to your Azure Subscription, Create a service request for technical support via the Azure Portal

  2. If you don't have a support plan, send mail to AzCommunity@microsoft.com, include your Subscription ID and a link to this Q&A thread (for context)
    My team will gladly connect you with the right Azure Monitor support channel. (add Attn:Femi to email subject.)

Looking forward to hearing for you soon.

Have a good weekend.


0 Votes 0 ·

0 Answers