resource "azurerm_monitor_autoscale_setting" "test" {
name = "AutoscaleSetting"
resource_group_name = "${azurerm_resource_group.main.name}"
location = "${azurerm_resource_group.main.location}"
target_resource_id = "${azurerm_app_service_plan.main.id}"
profile {
name = "defaultProfile"
capacity {
default = 1
minimum = 1
maximum = 10
}
rule {
metric_trigger {
metric_name = "Percentage CPU"
metric_resource_id = "${azurerm_app_service_plan.main.id}"
time_grain = "PT1M"
statistic = "Average"
time_window = "PT5M"
time_aggregation = "Average"
operator = "GreaterThan"
threshold = 80
}
scale_action {
direction = "Increase"
type = "ChangeCount"
value = "1"
cooldown = "PT1M"
}
}
rule {
metric_trigger {
metric_name = "Percentage CPU"
metric_resource_id = "${azurerm_app_service_plan.main.id}"
time_grain = "PT1M"
statistic = "Average"
time_window = "PT5M"
time_aggregation = "Average"
operator = "LessThan"
threshold = 80
}
scale_action {
direction = "Decrease"
type = "ChangeCount"
value = "1"
cooldown = "PT1M"
}
}}
我尝试在天蓝色的Terraform中设置自动缩放规则。这样做时会引发此错误。请对此提供帮助。这是什么错误,该错误如何解决?
错误:创建自动缩放设置“自动缩放设置”时出错(资源组“ sm-prod-resources”):Insights.AutoscaleSettingsClient#CreateOrUpdate:响应失败要求:StatusCode = 400-原始错误:autorest / azure:服务返回错误。 Status = 400代码=“ UnsupportedMetric”Message =“类型异常'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException'被抛出。”
错误表明它是UnsupportedMetric。根据Terraform中的文档,它描述如下:
metric_name-(必填),用于定义规则监视器,例如虚拟机规模集的CPU百分比和CpuPercentage for App Service Plan。
[我认为这只是您所犯的错误,“ Percentage CPU”的名称是针对虚拟机规模集的,您需要将其更改为“ CpuPercentage”,根据需要用于App Service Plan。有关详细信息,请参见metric_name。