gpt4 book ai didi

azure - 在azure中使用terraform为应用程序服务创建自动缩放规则时出错

转载 作者:行者123 更新时间:2023-12-03 15:44:01 26 4
gpt4 key购买 nike

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"
}
}}

我尝试在 azure 上的 terraform 中设置自动缩放规则。这样做时它抛出了这个错误。请帮忙解决这个问题。这个错误是什么?如何解决这个错误?

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."

最佳答案

该错误表明它是一个不支持的指标。根据Terraform中的文档,是这样描述的:

metric_name - (Required) The name of the metric that defines what therule monitors, such as Percentage CPU for Virtual Machine Scale Setsand CpuPercentage for App Service Plan.

我认为这只是您犯的一个错误,带有“Percentage CPU”的名称适用于虚拟机规模集,您需要将其更改为“CpuPercentage”,它适用于您的应用服务计划想。详情见metric_name .

关于azure - 在azure中使用terraform为应用程序服务创建自动缩放规则时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58657096/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com