UserP
UserP

Reputation: 314

What should be the operation name for creating a monitor alert using terraform

I am trying to create 2 alerts for a VM when it gets

  1. deleted
  2. powered off

I know that I have to use the below code for creating alerts based on operations but can't figure out what should be the operation name and category:

resource "azurerm_monitor_activity_log_alert" "main" {
  name                = "example-activitylogalert"
  resource_group_name = azurerm_resource_group.main.name
  scopes              = [azurerm_resource_group.main.id]
  description         = "description"

  criteria {
    resource_id    = azurerm_virtual_machine.example.id
    operation_name = "??"
    category= "??"
  }
}

Upvotes: 1

Views: 698

Answers (1)

Ansuman Bal
Ansuman Bal

Reputation: 11401

The Category should be always Administrative for these operations and as for the Operation names for the first one you should use "Microsoft.Compute/virtualMachines/delete" and the other one Microsoft.Compute/virtualMachines/PowerOff/Action.

Note: If you are not sure on what operations to be used you can go to the activity and create a alert from portal for a reference.

Reference:

Create, view, and manage activity log alerts in Azure Monitor - Azure Monitor | Microsoft Docs

Upvotes: 2

Related Questions