gpt4 book ai didi

terraform-provider-azure - 如何使用 Terraform 设置资源健康警报条件

转载 作者:行者123 更新时间:2023-12-05 06:09:11 25 4
gpt4 key购买 nike

我正在尝试使用 terraform 创建资源健康警报,它非常简单非常 terraform

resource "azurerm_monitor_activity_log_alert" "resourcehealth" {
name = "${var.client_initial}-MCS Optimise Resource Health"
description = "${var.client_initial}-MCS Optimise Resource Health Alerts"
resource_group_name = var.resource_group_name
scopes = [var.scopes]
criteria {
category = "ResourceHealth"
}

action {
action_group_id = var.action_group_id
}
tags = var.tags
}

但是,我发现它缺乏进一步设置粒度警报条件的能力,比如我们只想在当前资源状态降级或不可用时发出警报,并且响应类型是平台启动的。 Terraform 似乎满足了所有条件。

最佳答案

单一资源范围

resource "azurerm_monitor_activity_log_alert" "resourcehealth" {
name = "${var.client_initial}-MCS Optimise Resource Health"
description = "${var.client_initial}-MCS Optimise Resource Health Alerts"
resource_group_name = var.resource_group_name
scopes = [var.scope]
criteria {
resource_id = var.scope
operation_name = "Microsoft.Resourcehealth/healthevent/Activated/action"
category = "ResourceHealth"
}

action {
action_group_id = var.action_group_id
}
tags = var.tags
}

对于多个资源使用 for_each

resource "azurerm_monitor_activity_log_alert" "resourcehealth" {
for_each = var.scopes

name = "${var.client_initial}-MCS Optimise Resource Health"
description = "${var.client_initial}-MCS Optimise Resource Health Alerts"
resource_group_name = var.resource_group_name
scopes = [each.key]
criteria {
resource_id = each.key
operation_name = "Microsoft.Resourcehealth/healthevent/Activated/action"
category = "ResourceHealth"
}

action {
action_group_id = var.action_group_id
}
tags = var.tags
}

关于terraform-provider-azure - 如何使用 Terraform 设置资源健康警报条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64905009/

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