-
Notifications
You must be signed in to change notification settings - Fork 3
/
monitoring.tf
76 lines (61 loc) · 1.87 KB
/
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
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
73
74
75
76
resource "random_id" "log_analytics_workspace_name_suffix" {
byte_length = 8
}
resource "azurerm_log_analytics_workspace" "logs" {
# The WorkSpace name has to be unique across the whole of azure, not just the current subscription/tenant.
name = "${data.azurerm_resource_group.aks.name}-${random_id.log_analytics_workspace_name_suffix.dec}"
location = data.azurerm_resource_group.aks.location
resource_group_name = data.azurerm_resource_group.aks.name
sku = var.log_analytics_workspace_sku
tags = var.tags
}
resource "azurerm_log_analytics_solution" "logs" {
solution_name = "ContainerInsights"
location = azurerm_log_analytics_workspace.logs.location
resource_group_name = data.azurerm_resource_group.aks.name
workspace_resource_id = azurerm_log_analytics_workspace.logs.id
workspace_name = azurerm_log_analytics_workspace.logs.name
plan {
publisher = "Microsoft"
product = "OMSGallery/ContainerInsights"
}
tags = var.tags
lifecycle {
ignore_changes = [
tags
]
}
}
resource "azurerm_monitor_diagnostic_setting" "control_plane" {
name = "AKS Control Plane Logging"
target_resource_id = azurerm_kubernetes_cluster.aks.id
log_analytics_workspace_id = azurerm_log_analytics_workspace.logs.id
enabled_log {
category = "cloud-controller-manager"
}
enabled_log {
category = "cluster-autoscaler"
}
enabled_log {
category = "csi-azuredisk-controller"
}
enabled_log {
category = "csi-azurefile-controller"
}
enabled_log {
category = "csi-snapshot-controller"
}
enabled_log {
category = "kube-apiserver"
}
enabled_log {
category = "kube-controller-manager"
}
enabled_log {
category = "kube-scheduler"
}
metric {
category = "AllMetrics"
enabled = false
}
}