使用 Terraform 在 Aazure Postgresql 上设置警报的问题
issue to setup alert onAazure Postgresql using Terraform
我使用 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
}
}
Error Screenshot
以下 Microsoft DOC link 是警报规范的参考-
https://docs.microsoft.com/en-us/azure/azure-monitor/platform/metrics-supported
您只需将标准块中的 metric_name
值从 CPU percent
更改为 cpu_percent
。它应该是 Metric 的名称,而不是 Metric Display Name。
我使用 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
}
}
Error Screenshot
以下 Microsoft DOC link 是警报规范的参考-
https://docs.microsoft.com/en-us/azure/azure-monitor/platform/metrics-supported
您只需将标准块中的 metric_name
值从 CPU percent
更改为 cpu_percent
。它应该是 Metric 的名称,而不是 Metric Display Name。