-
Notifications
You must be signed in to change notification settings - Fork 5
/
r-aks-monitoring.tf
44 lines (38 loc) · 1.56 KB
/
r-aks-monitoring.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
resource "azurerm_monitor_data_collection_rule" "dcr" {
count = var.data_collection_rule.enabled ? 1 : 0
name = local.dcr_name
location = var.location
resource_group_name = var.resource_group_name
destinations {
log_analytics {
name = "default-workspace"
workspace_resource_id = coalesce(var.data_collection_rule.custom_log_analytics_workspace_id, local.default_log_analytics)
}
}
data_flow {
destinations = ["default-workspace"]
streams = var.data_collection_rule.data_streams
}
data_sources {
extension {
name = "ContainerInsightsExtension"
extension_name = "ContainerInsights"
streams = var.data_collection_rule.data_streams
extension_json = jsonencode({
dataCollectionSettings = {
enableContainerLogV2 = var.data_collection_rule.container_log_v2_enabled
interval = var.data_collection_rule.data_collection_interval
namespaceFilteringMode = var.data_collection_rule.namespace_filtering_mode
namespaces = var.data_collection_rule.namespaces_filter
}
})
}
}
tags = merge(local.default_tags, var.extra_tags)
}
resource "azurerm_monitor_data_collection_rule_association" "dcr" {
count = var.data_collection_rule.enabled ? 1 : 0
name = azurerm_kubernetes_cluster.aks.name
target_resource_id = azurerm_kubernetes_cluster.aks.id
data_collection_rule_id = azurerm_monitor_data_collection_rule.dcr[0].id
}