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. 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. Status=400 Code="UnsupportedMetric" Message="Exception of type 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown."
In your browser, open the Azure portal. In your App Service app page, from the left menu, select Scale Up (App Service plan). Choose your tier, and then select Apply. Select the different categories (for example, Production) and also See additional options to show more tiers.
Use Azure Monitor autoscale. Azure Monitor autoscale provide a common set of autoscaling functionality for virtual machine scale sets, Azure App Service, and Azure Cloud Service. Scaling can be performed on a schedule, or based on a runtime metric, such as CPU or memory usage.
The error shows that it's an UnsupportedMetric. According to the document in Terraform, it describes like this:
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.
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. For details, see metric_name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With