Skip to content

Commit 5decee0

Browse files
committed
DTOSS-00000: Add alerting availability test
The application insights web availability test was firing but it was not firing the alert to the email group because the azurerm_monitor_metric_alert resource was missing. This simply adds this alert into the child module.
1 parent eb187eb commit 5decee0

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

infrastructure/modules/application-insights-availability-test/main.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,21 @@ resource "azurerm_application_insights_standard_web_test" "this" {
1414

1515
geo_locations = var.geo_locations
1616
}
17+
18+
resource "azurerm_monitor_metric_alert" "this" {
19+
name = "${var.name}-availability-alert"
20+
resource_group_name = var.resource_group_name
21+
scopes = [azurerm_application_insights_standard_web_test.this.id, var.application_insights_id]
22+
description = "availability test alert"
23+
severity = 0
24+
25+
application_insights_web_test_location_availability_criteria {
26+
web_test_id = azurerm_application_insights_standard_web_test.this.id
27+
component_id = var.application_insights_id
28+
failed_location_count = 2
29+
}
30+
31+
action {
32+
action_group_id = var.action_group_id
33+
}
34+
}

infrastructure/modules/application-insights-availability-test/tfdocs.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
The following input variables are required:
66

7+
### <a name="input_action_group_id"></a> [action\_group\_id](#input\_action\_group\_id)
8+
9+
Description: ID of the action group to notify.
10+
11+
Type: `string`
12+
713
### <a name="input_application_insights_id"></a> [application\_insights\_id](#input\_application\_insights\_id)
814

915
Description: The Application Insights resource id to associate the availability test with
@@ -78,3 +84,4 @@ Default: `30`
7884
The following resources are used by this module:
7985

8086
- [azurerm_application_insights_standard_web_test.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_insights_standard_web_test) (resource)
87+
- [azurerm_monitor_metric_alert.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert) (resource)

infrastructure/modules/application-insights-availability-test/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ variable "application_insights_id" {
2323
description = "The Application Insights resource id to associate the availability test with"
2424
}
2525

26+
variable "action_group_id" {
27+
type = string
28+
description = "ID of the action group to notify."
29+
}
30+
2631
variable "frequency" {
2732
type = number
2833
default = 300

0 commit comments

Comments
 (0)