Skip to content

Commit 0ce4573

Browse files
Auto update
1 parent 252c132 commit 0ce4573

File tree

3 files changed

+64
-66
lines changed

3 files changed

+64
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Add temporary\_name\_for\_rotation in azurerm\_kubernetes\_cluster\_node\_pool [\#638](https://github.com/Azure/terraform-azurerm-aks/pull/638) ([zioproto](https://github.com/zioproto))
1010
- Release `v10.0.0` [\#636](https://github.com/Azure/terraform-azurerm-aks/pull/636) ([lonegunmanb](https://github.com/lonegunmanb))
1111
- Add nonsensitive around for\_each argument [\#631](https://github.com/Azure/terraform-azurerm-aks/pull/631) ([zioproto](https://github.com/zioproto))
12+
- Implement Data Collection Rule for Container Insights [\#623](https://github.com/Azure/terraform-azurerm-aks/pull/623) ([zioproto](https://github.com/zioproto))
1213
- Cannot set both `client_id` and `identity_ids` variables. [\#622](https://github.com/Azure/terraform-azurerm-aks/pull/622) ([zioproto](https://github.com/zioproto))
1314
- support the dns\_zone\_ids property in the web\_app\_routing block [\#606](https://github.com/Azure/terraform-azurerm-aks/pull/606) ([zioproto](https://github.com/zioproto))
1415
- resource\_group: remove data source + location required [\#603](https://github.com/Azure/terraform-azurerm-aks/pull/603) ([DeviaVir](https://github.com/DeviaVir))

log_analytics.tf

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,40 +87,33 @@ locals {
8787
}
8888

8989
resource "azurerm_monitor_data_collection_rule" "dcr" {
90-
count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0
90+
count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0
91+
92+
location = local.dcr_location
9193
name = "MSCI-${local.dcr_location}-${azurerm_kubernetes_cluster.main.name}"
9294
resource_group_name = var.resource_group_name
93-
location = local.dcr_location
95+
description = "DCR for Azure Monitor Container Insights"
9496
tags = var.tags
9597

96-
destinations {
97-
log_analytics {
98-
workspace_resource_id = local.log_analytics_workspace.id
99-
name = local.log_analytics_workspace.name
100-
}
101-
}
102-
10398
data_flow {
104-
streams = var.monitor_data_collection_rule_extensions_streams
10599
destinations = [local.log_analytics_workspace.name]
100+
streams = var.monitor_data_collection_rule_extensions_streams
106101
}
107-
108102
data_flow {
109-
streams = ["Microsoft-Syslog"]
110103
destinations = [local.log_analytics_workspace.name]
104+
streams = ["Microsoft-Syslog"]
111105
}
112-
113-
data_sources {
114-
syslog {
115-
streams = ["Microsoft-Syslog"]
116-
facility_names = var.monitor_data_collection_rule_data_sources_syslog_facilities
117-
log_levels = var.monitor_data_collection_rule_data_sources_syslog_levels
118-
name = "sysLogsDataSource"
106+
destinations {
107+
log_analytics {
108+
name = local.log_analytics_workspace.name
109+
workspace_resource_id = local.log_analytics_workspace.id
119110
}
120-
111+
}
112+
data_sources {
121113
extension {
122-
streams = var.monitor_data_collection_rule_extensions_streams
123114
extension_name = "ContainerInsights"
115+
name = "ContainerInsightsExtension"
116+
streams = var.monitor_data_collection_rule_extensions_streams
124117
extension_json = jsonencode({
125118
"dataCollectionSettings" : {
126119
interval = var.data_collection_settings.data_collection_interval
@@ -129,17 +122,21 @@ resource "azurerm_monitor_data_collection_rule" "dcr" {
129122
enableContainerLogV2 = var.data_collection_settings.container_log_v2_enabled
130123
}
131124
})
132-
name = "ContainerInsightsExtension"
125+
}
126+
syslog {
127+
facility_names = var.monitor_data_collection_rule_data_sources_syslog_facilities
128+
log_levels = var.monitor_data_collection_rule_data_sources_syslog_levels
129+
name = "sysLogsDataSource"
130+
streams = ["Microsoft-Syslog"]
133131
}
134132
}
135-
136-
description = "DCR for Azure Monitor Container Insights"
137133
}
138134

139135
resource "azurerm_monitor_data_collection_rule_association" "dcra" {
140-
count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0
141-
name = "ContainerInsightsExtension"
136+
count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0
137+
142138
target_resource_id = azurerm_kubernetes_cluster.main.id
143139
data_collection_rule_id = azurerm_monitor_data_collection_rule.dcr[0].id
144140
description = "Association of container insights data collection rule. Deleting this association will break the data collection for this AKS Cluster."
141+
name = "ContainerInsightsExtension"
145142
}

variables.tf

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,28 @@ variable "create_role_assignments_for_application_gateway" {
454454
nullable = false
455455
}
456456

457+
variable "data_collection_settings" {
458+
type = object({
459+
data_collection_interval = string
460+
namespace_filtering_mode_for_data_collection = string
461+
namespaces_for_data_collection = list(string)
462+
container_log_v2_enabled = bool
463+
})
464+
default = {
465+
data_collection_interval = "1m"
466+
namespace_filtering_mode_for_data_collection = "Off"
467+
namespaces_for_data_collection = ["kube-system", "gatekeeper-system", "azure-arc"]
468+
container_log_v2_enabled = true
469+
}
470+
description = <<-EOT
471+
`data_collection_interval` - Determines how often the agent collects data. Valid values are 1m - 30m in 1m intervals. Default is 1m.
472+
`namespace_filtering_mode_for_data_collection` - Can be 'Include', 'Exclude', or 'Off'. Determines how namespaces are filtered for data collection.
473+
`namespaces_for_data_collection` - List of Kubernetes namespaces for data collection based on the filtering mode.
474+
`container_log_v2_enabled` - Flag to enable the ContainerLogV2 schema for collecting logs.
475+
See more details: https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-data-collection-configure?tabs=cli#configure-dcr-with-azure-portal-1
476+
EOT
477+
}
478+
457479
variable "default_node_pool_fips_enabled" {
458480
type = bool
459481
default = null
@@ -882,6 +904,24 @@ variable "microsoft_defender_enabled" {
882904
nullable = false
883905
}
884906

907+
variable "monitor_data_collection_rule_data_sources_syslog_facilities" {
908+
type = list(string)
909+
default = ["auth", "authpriv", "cron", "daemon", "mark", "kern", "local0", "local1", "local2", "local3", "local4", "local5", "local6", "local7", "lpr", "mail", "news", "syslog", "user", "uucp"]
910+
description = "Syslog supported facilities as documented here: https://learn.microsoft.com/en-us/azure/azure-monitor/agents/data-sources-syslog"
911+
}
912+
913+
variable "monitor_data_collection_rule_data_sources_syslog_levels" {
914+
type = list(string)
915+
default = ["Debug", "Info", "Notice", "Warning", "Error", "Critical", "Alert", "Emergency"]
916+
description = "List of syslog levels"
917+
}
918+
919+
variable "monitor_data_collection_rule_extensions_streams" {
920+
type = list(any)
921+
default = ["Microsoft-ContainerLog", "Microsoft-ContainerLogV2", "Microsoft-KubeEvents", "Microsoft-KubePodInventory", "Microsoft-KubeNodeInventory", "Microsoft-KubePVInventory", "Microsoft-KubeServices", "Microsoft-KubeMonAgentEvents", "Microsoft-InsightsMetrics", "Microsoft-ContainerInventory", "Microsoft-ContainerNodeInventory", "Microsoft-Perf"]
922+
description = "An array of container insights table streams. See documentation in DCR for a list of the valid streams and their corresponding table: https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-data-collection-configure?tabs=portal#stream-values-in-dcr"
923+
}
924+
885925
variable "monitor_metrics" {
886926
type = object({
887927
annotations_allowed = optional(string)
@@ -1479,43 +1519,3 @@ variable "workload_identity_enabled" {
14791519
default = false
14801520
description = "Enable or Disable Workload Identity. Defaults to false."
14811521
}
1482-
1483-
variable "monitor_data_collection_rule_extensions_streams" {
1484-
type = list(any)
1485-
default = ["Microsoft-ContainerLog", "Microsoft-ContainerLogV2", "Microsoft-KubeEvents", "Microsoft-KubePodInventory", "Microsoft-KubeNodeInventory", "Microsoft-KubePVInventory", "Microsoft-KubeServices", "Microsoft-KubeMonAgentEvents", "Microsoft-InsightsMetrics", "Microsoft-ContainerInventory", "Microsoft-ContainerNodeInventory", "Microsoft-Perf"]
1486-
description = "An array of container insights table streams. See documentation in DCR for a list of the valid streams and their corresponding table: https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-data-collection-configure?tabs=portal#stream-values-in-dcr"
1487-
}
1488-
1489-
variable "monitor_data_collection_rule_data_sources_syslog_levels" {
1490-
type = list(string)
1491-
default = ["Debug", "Info", "Notice", "Warning", "Error", "Critical", "Alert", "Emergency"]
1492-
description = "List of syslog levels"
1493-
}
1494-
1495-
variable "monitor_data_collection_rule_data_sources_syslog_facilities" {
1496-
type = list(string)
1497-
default = ["auth", "authpriv", "cron", "daemon", "mark", "kern", "local0", "local1", "local2", "local3", "local4", "local5", "local6", "local7", "lpr", "mail", "news", "syslog", "user", "uucp"]
1498-
description = "Syslog supported facilities as documented here: https://learn.microsoft.com/en-us/azure/azure-monitor/agents/data-sources-syslog"
1499-
}
1500-
1501-
variable "data_collection_settings" {
1502-
type = object({
1503-
data_collection_interval = string
1504-
namespace_filtering_mode_for_data_collection = string
1505-
namespaces_for_data_collection = list(string)
1506-
container_log_v2_enabled = bool
1507-
})
1508-
default = {
1509-
data_collection_interval = "1m"
1510-
namespace_filtering_mode_for_data_collection = "Off"
1511-
namespaces_for_data_collection = ["kube-system", "gatekeeper-system", "azure-arc"]
1512-
container_log_v2_enabled = true
1513-
}
1514-
description = <<-EOT
1515-
`data_collection_interval` - Determines how often the agent collects data. Valid values are 1m - 30m in 1m intervals. Default is 1m.
1516-
`namespace_filtering_mode_for_data_collection` - Can be 'Include', 'Exclude', or 'Off'. Determines how namespaces are filtered for data collection.
1517-
`namespaces_for_data_collection` - List of Kubernetes namespaces for data collection based on the filtering mode.
1518-
`container_log_v2_enabled` - Flag to enable the ContainerLogV2 schema for collecting logs.
1519-
See more details: https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-data-collection-configure?tabs=cli#configure-dcr-with-azure-portal-1
1520-
EOT
1521-
}

0 commit comments

Comments
 (0)