简体   繁体   English

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

[英]Error creating auto-scaling rule for app service using terraform in azure

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

I tried setting an auto scaling rule in terraform on azure.我尝试在 azure 上的 terraform 中设置自动缩放规则。 While doing so it threw this error.这样做时会引发此错误。 kindly help with this.请帮忙。 What is this error and how can this error be solved?这个错误是什么?如何解决这个错误?

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.错误:创建自动缩放设置“AutoscaleSetting”(资源组“sm-prod-resources”)时出错:insights.AutoscaleSettingsClient#CreateOrUpdate:响应请求失败:StatusCode=400 - 原始错误:autorest/azure:服务返回错误。 Status=400 Code="UnsupportedMetric" Message="Exception of type 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown." Status=400 Code="UnsupportedMetric" Message="抛出了 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' 类型的异常。"

The error shows that it's an UnsupportedMetric .该错误表明它是UnsupportedMetric According to the document in Terraform, it describes like this:根据 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. metric_name -(必需)定义规则监控的指标的名称,例如虚拟机规模集的百分比 CPU 和应用服务计划的 CpuPercentage。

I think it's just a mistake you made, the name with "Percentage CPU" is for Virtual Machine Scale Sets, you need to change it into " CpuPercentage ", it's for App Service Plan as you want.我认为这只是您犯的一个错误,“百分比 CPU”的名称是虚拟机规模集,您需要将其更改为“ CpuPercentage ”,它是您想要的应用服务计划。 For details, see metric_name .有关详细信息,请参阅metric_name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM