1

我已经使用 Terraform azure 创建了带有 cpu 百分比的客户警报的 postgresql,并且未找到其显示的错误度量名称

请检查以下代码。

provider "azurerm" {
  features {}
  subscription_id = "***************"//add subscription ID
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_postgresql_server" "example" {
  name                = "example-psqlserver"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  administrator_login          = "psqladminun"
  administrator_login_password = "H@Sh1CoR3!"

  sku_name   = "GP_Gen5_4"
  version    = "9.6"
  storage_mb = 640000

  backup_retention_days        = 7
  geo_redundant_backup_enabled = true
  auto_grow_enabled            = true

  public_network_access_enabled    = false
  ssl_enforcement_enabled          = true
  ssl_minimal_tls_version_enforced = "TLS1_2"
}

resource "azurerm_monitor_action_group" "actiongrp" {
  name                = "Postgresql-AlertsActions1"
  resource_group_name =  azurerm_resource_group.example.name
  short_name          = "Postgresql1"

  email_receiver {
    name          = "sendtoadmin"
    email_address = "testing@gmail.com"
  }
}

////This alert is Trigger once the CPU usage is goes more than 70 
resource "azurerm_monitor_metric_alert" "alert0" {

  name                = "testing"
  resource_group_name =  azurerm_resource_group.example.name
  scopes              = [azurerm_postgresql_server.example.id]
  description         = "Action will be triggered when CPU Utilization count is greater than 70."

  criteria {
    metric_namespace = "Microsoft.DBforPostgreSQL/servers"#"Microsoft.DBforPostgreSQL/servers"
    metric_name      = "CPU percent"  
    aggregation      = "Average"
    operator         = "GreaterThan"
    threshold        = 70
  }

  action {
    action_group_id = azurerm_monitor_action_group.actiongrp.id
  }
}

错误截图

下面的 Microsoft DOC 链接是参考警报规范 -
https://docs.microsoft.com/en-us/azure/azure-monitor/platform/metrics-supported

4

1 回答 1

1

您只需要将metric_name条件块中的值从更改CPU percentcpu_percent. 它应该是Metric的名称,而不是Metric Display Name

于 2020-06-09T02:16:26.410 回答