I want to add another criteria but I get this error When the alert rule contains multiple criteria, the use of dimensions is limited to one value per dimension within each criterion
resource "azurerm_monitor_metric_alert" "example" {
name = "example-metricalert"
resource_group_name = azurerm_resource_group.main.name
scopes = [azurerm_storage_account.to_monitor.id]
description = "Action will be triggered when Transactions count is greater than 50."
criteria {
metric_namespace = "Microsoft.Storage/storageAccounts"
metric_name = "Transactions"
aggregation = "Total"
operator = "GreaterThan"
threshold = 50
dimension {
name = "ApiName"
operator = "Include"
values = ["*"]
}
}
criteria {
metric_namespace = "Microsoft.Storage/storageAccounts"
metric_name = "Transactions"
aggregation = "Total"
operator = "GreaterThan"
threshold = 50
dimension {
name = "ApiName"
operator = "Include"
values = ["*"]
}
}
action {
action_group_id = azurerm_monitor_action_group.main.id
}
You cannot set 2 conditions for a alert rule when you have set multiple dimensions for one condition i.e. you can't use Dimension Value as ["*"]
.
If you want multiple conditions in one Metric Alert then you will have to give some dimension value for one criteria and same dimension for other criteria as well or you can also not use dimension block for both .
For example, you can refer the below code:
resource "azurerm_monitor_metric_alert" "example" {
name = "example-metricalert"
resource_group_name = azurerm_resource_group.main.name
scopes = [azurerm_storage_account.to_monitor.id]
description = "Action will be triggered when Transactions count is greater than 50."
criteria {
metric_namespace = "Microsoft.Storage/storageAccounts"
metric_name = "Transactions"
aggregation = "Total"
operator = "GreaterThan"
threshold = 50
dimension {
name = "ApiName"
operator = "Include"
values = ["GetBlobServiceProperties"]
}
}
criteria {
metric_namespace = "Microsoft.Storage/storageAccounts"
metric_name = "SuccessE2ELatency"
aggregation = "Average"
operator = "GreaterThan"
threshold = 10
dimension {
name = "ApiName"
operator = "Include"
values = ["GetBlobServiceProperties"]
}
}
action {
action_group_id = azurerm_monitor_action_group.main.id
}
}
resource "azurerm_monitor_metric_alert" "example1" {
name = "example1-metricalert"
resource_group_name = azurerm_resource_group.main.name
scopes = [azurerm_storage_account.to_monitor.id]
description = "Action will be triggered when Transactions count is greater than 50."
criteria {
metric_namespace = "Microsoft.Storage/storageAccounts"
metric_name = "Transactions"
aggregation = "Total"
operator = "GreaterThan"
threshold = 50
}
criteria {
metric_namespace = "Microsoft.Storage/storageAccounts"
metric_name = "SuccessE2ELatency"
aggregation = "Average"
operator = "GreaterThan"
threshold = 10
}
action {
action_group_id = azurerm_monitor_action_group.main.id
}
}