-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathapp-insights.tf
72 lines (60 loc) · 2.48 KB
/
app-insights.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
resource "azurerm_application_insights" "main" {
count = local.enable_app_insights_integration ? 1 : 0
name = "${local.resource_prefix}-insights"
location = local.resource_group.location
resource_group_name = local.resource_group.name
application_type = "web"
workspace_id = azurerm_log_analytics_workspace.app_insights[0].id
retention_in_days = local.app_insights_retention_days
tags = local.tags
}
resource "azurerm_application_insights" "function_apps" {
for_each = local.enable_app_insights_integration ? merge(local.linux_function_apps, local.linux_function_health_insights_api) : {}
name = "${local.resource_prefix}-${each.key}-insights"
location = local.resource_group.location
resource_group_name = local.resource_group.name
application_type = "web"
workspace_id = azurerm_log_analytics_workspace.app_insights[0].id
retention_in_days = local.app_insights_retention_days
tags = local.tags
}
resource "azurerm_log_analytics_workspace" "app_insights" {
count = local.enable_app_insights_integration ? 1 : 0
name = "${local.resource_prefix}-insights"
location = local.resource_group.location
resource_group_name = local.resource_group.name
sku = "PerGB2018"
retention_in_days = local.app_insights_retention_days
tags = local.tags
}
resource "azurerm_application_insights_standard_web_test" "main" {
count = local.enable_app_insights_integration && local.enable_monitoring ? 1 : 0
name = "${local.resource_prefix}-http"
resource_group_name = local.resource_group.name
location = local.resource_group.location
application_insights_id = azurerm_application_insights.main[0].id
timeout = 10
description = "Regional HTTP availability check"
enabled = true
retry_enabled = true
geo_locations = [
"emea-nl-ams-azr", # West Europe
"emea-se-sto-edge", # UK West
"emea-ru-msa-edge" # UK South
]
request {
url = local.monitor_http_availability_url
http_verb = "HEAD"
header {
name = "X-AppInsights-HttpTest"
value = azurerm_application_insights.main[0].name
}
}
validation_rules {
expected_status_code = 0 # 0 = response code < 400
}
tags = merge(
local.tags,
{ "hidden-link:${azurerm_application_insights.main[0].id}" = "Resource" },
)
}