Azure Monitor - Terraform 警报不会触发,除非创建门户创建警报

时间:2021-06-19 22:44:45

标签: azure azure-monitor

我使用以下 Terraform 代码创建了 Azure Monitor 警报:

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
}

但是,除非我在门户中手动创建警报,甚至相同的警报和指标等,否则这不会触发任何警报(电子邮件/短信)。哪个顺序无关紧要;我在TF中创建了上述警报,然后手动创建另一个警报;或者我手动创建警报然后运行 ​​TF 代码。但无论如何,如果没有手动创建的警报,TF 警报不会触发。

有其他人看到过这个问题吗?

我已经将来自 PS cmdlet:Get-AzMetricAlertRuleV2 的数据与创建的警报进行了比较,它们是相同的。

有什么想法吗?

0 个答案:

没有答案