在 Azure 中使用 Terraform 为应用服务创建自动缩放规则时出错
Error creating auto-scaling rule for app service using terraform in azure
-
azure
-
azure-web-app-service
-
azure-app-service-plans
-
terraform-provider-azure
-
app-service-environment
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 on azure 中设置自动缩放规则。这样做时它抛出了这个错误。请帮忙解决这个问题。这是什么错误,如何解决?
Error : Error creating AutoScale Setting "AutoscaleSetting" (Resource
Group "sm-prod-resources"):
insights.AutoscaleSettingsClient#CreateOrUpdate: Failure responding to
request: StatusCode=400 -- Original Error: autorest/azure: Service
returned an error. Status=400 Code="UnsupportedMetric"
Message="Exception of type
'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException'
was thrown."
错误表明它是一个 UnsupportedMetric。根据Terraform中的文档,是这样描述的:
metric_name - (Required) The name of the metric that defines what the
rule monitors, such as Percentage CPU for Virtual Machine Scale Sets
and CpuPercentage for App Service Plan.
我认为这只是你犯的一个错误,带有“Percentage CPU”的名称是虚拟机规模集的名称,你需要将其更改为“CpuPercentage ",这是你想要的应用程序服务计划。有关详细信息,请参阅 metric_name。
azure
azure-web-app-service
azure-app-service-plans
terraform-provider-azure
app-service-environment
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 on azure 中设置自动缩放规则。这样做时它抛出了这个错误。请帮忙解决这个问题。这是什么错误,如何解决?
Error : Error creating AutoScale Setting "AutoscaleSetting" (Resource Group "sm-prod-resources"): insights.AutoscaleSettingsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="UnsupportedMetric" Message="Exception of type 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown."
错误表明它是一个 UnsupportedMetric。根据Terraform中的文档,是这样描述的:
metric_name - (Required) The name of the metric that defines what the rule monitors, such as Percentage CPU for Virtual Machine Scale Sets and CpuPercentage for App Service Plan.
我认为这只是你犯的一个错误,带有“Percentage CPU”的名称是虚拟机规模集的名称,你需要将其更改为“CpuPercentage ",这是你想要的应用程序服务计划。有关详细信息,请参阅 metric_name。