我正在尝试为我的应用程序服务设置一个 azurerm_monitor_metric_alert,我想定义一个警报,它涵盖了 terraform 正在构建的所有应用程序服务。
我构建的应用服务有两个维度,一个基于区域(最多两个),另一个基于部署到每个应用服务计划的应用服务数量(未知数字,下例中为两个)。
我希望我可以做类似的事情:
resource "azurerm_monitor_metric_alert" "disk1" {
name = "AppService-diskSpace-Sev1"
resource_group_name = azurerm_resource_group.location1[0].name
scopes = ["${azurerm_app_service.location1.*.id}","${azurerm_app_service.location2.*.id}"]
description = "Disk space over 90 percent"
window_size = "PT6H"
frequency = "PT1H"
criteria {
metric_namespace = "Microsoft.Web/sites"
metric_name = "FileSystemUsage"
aggregation = "Average"
operator = "GreaterThan"
threshold = 241591910400 # 90% of 250Gb in bytes
}
severity = 1
}
但我收到如下错误:
Error: Incorrect attribute value type
on ..\..\..\infra\terraform\global\web\main.tf line 343, in resource "azurerm_monitor_metric_alert" "disk1":
343: scopes = ["${azurerm_app_service.location1.*.id}","${azurerm_app_service.location2.*.id}"]
|----------------
| azurerm_app_service.location is tuple with 2 elements
| azurerm_app_service.location2 is tuple with 2 elements
Inappropriate value for attribute "scopes": element 0: string required.
医生说,我尝试了许多不同的选项,但都产生错误
“应应用度量标准的一组资源 ID 字符串”
但我不确定在这种情况下“一组字符串”是什么意思。
- 编辑在下面的评论之后,我尝试了我希望被建议的内容,但我仍然遇到错误:
concat(azurerm_app_service.location.*.id)
返回
Error: scopes: attribute supports 1 item maximum, config has 2 declared.
["${azurerm_app_service.location.*.id}"]
返回
Inappropriate value for attribute "scopes": element 0: string required.
"${azurerm_app_service.web.*.id}"
返回
Error: scopes: attribute supports 1 item maximum, config has 2 declare