我正在尝试使用命令为我的虚拟机创建缩放规则
az monitor autoscale rule create --resource-group MyGroup --resource "cc-insight" --resource-type "Microsoft.Insights/components" --autoscale-name autoscale --condition "cc-response-time-view > 2000 avg 5m" --scale out 1
但得到
Exception of type 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown.. [Code: "UnsupportedMetric"]
虽然可以通过 App Insights 访问指标
答案1
经过一些手动测试,我解决了这个问题。
以下是 Terraform 的自定义指标规则配置。请记住,所有自定义指标名称均以“customMetrics/您的指标名称”
rule {
metric_trigger {
metric_name = "customMetrics/cc-response-time-view"
metric_resource_id = azurerm_application_insights.insight.id
time_grain = "PT1M"
statistic = "Average"
time_window = "PT5M"
time_aggregation = "Average"
operator = "LessThan"
threshold = 1500
}
scale_action {
direction = "Decrease"
type = "ChangeCount"
value = "1"
cooldown = "PT1M"
}
}
对于使用控制台的用户,请不要忘记将命名空间设置为“microsoft.insights/组件/kusto”