# Azure Monitor alert A metric alert routed to an action group. `scopes` is the resource being watched. ```hcl variable "watched_id" { type = string } variable "on_call_email" { type = string } resource "azurerm_monitor_action_group" "on_call" { name = "ag-on-call" resource_group_name = var.resource_group_name short_name = "oncall" email_receiver { name = "on-call" email_address = var.on_call_email } } resource "azurerm_monitor_metric_alert" "cpu" { name = "alert-cpu" resource_group_name = var.resource_group_name scopes = [var.watched_id] severity = 2 frequency = "PT5M" window_size = "PT15M" criteria { metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers" metric_name = "cpu_percent" aggregation = "Average" operator = "GreaterThan" threshold = 80 } action { action_group_id = azurerm_monitor_action_group.on_call.id } } ```