Reputation: 87
resource "azurerm_monitor_metric_alert" "exception_alert_test_incoming_orders" {
name = "IncomingOrderTest"
resource_group_name = "${var.azurerm_resource_group_name}"
scopes = ["${azurerm_application_insights.app_insights_test.id}"]
enabled = "${var.test_insight_alerts_enabled}"
description = "Alert due to 0 incoming orders on last 24 hours (Test)"
frequency = "PT1H"
window_size = "P1D"
criteria {
metric_namespace = "Azure.ApplicationInsights"
metric_name = "IncomingOrder"
aggregation = "Count"
operator = "Equals"
threshold = 0
}
action {
action_group_id = "${azurerm_monitor_action_group.monitor_alert_action_test.id}"
}
}
The alerts are not getting trigerred the variables are correct , and not sure about the metric_namespace.
Upvotes: 1
Views: 1261
Reputation: 7933
For custom metrics use: metric_namespace = "azure.applicationinsights"
.
E.g.:
resource "azurerm_monitor_metric_alert" "example" {
name = "example-metricalert"
resource_group_name = azurerm_resource_group.example.name
scopes = [azurerm_application_insights.example.id]
criteria {
metric_namespace = "azure.applicationinsights"
metric_name = "your_custom_metric_name"
aggregation = "Total"
operator = "GreaterThan"
threshold = 90
}
# ... other configuration ...
}
Upvotes: 0
Reputation: 578
It appears that you need to use monitor_scheduled_query_rules_alert to monitor and alert on custom metrics.
Upvotes: 0
Reputation: 1251
metric_namespace
needs to represent the azure resource type.
For example: "Microsoft.Storage/storageAccounts"
as this is where the metric for the alert is to be generated.
I believe for application insight alerts the metric_namespace
ismicrosoft.insights/components
.
Everything else looks good!
Upvotes: 0