''' This is the approach i followed to create the alerts at resource level ( storage account).I am looking to create the alerts for different resources in log analytics instead of creating at resource level '''
data "azurerm_storage_account" "stro" {
name = "straccount18"
resource_group_name = azurerm_resource_group.rg.name
}
resource "azurerm_monitor_metric_alert" "AlertForLog" {
name = "metricalert"
resource_group_name = azurerm_resource_group.rg.name
scopes = [data.azurerm_storage_account.stro.id]
description = "Alert generation demo"
window_size = "PT1H"
severity = 0
criteria {
metric_namespace = "Microsoft.Storage/storageAccounts"
metric_name = "UsedCapacity"
aggregation = "Average"
operator = "GreaterThan"
threshold = 85
}
CodePudding user response:
You can do it by setting up query rules alerts as described in here https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert and enabling Storage Analytics as described in here
Query Storage Analytics Logs in Log Analytics: https://azure.microsoft.com/fr-fr/blog/query-azure-storage-analytics-logs-in-azure-log-analytics/
Sotage Analytics: https://docs.microsoft.com/en-us/azure/storage/common/storage-analytics