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