-
Notifications
You must be signed in to change notification settings - Fork 3
/
alerts.tf
186 lines (177 loc) · 6.79 KB
/
alerts.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
resource "kubernetes_manifest" "prometheusrule_certificate_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "certificate-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "certificate-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/certificate_alerts/certificate_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/certificate_alerts/certificate_rules.yaml", {
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_container_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "container-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "container-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/container_alerts/container_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/container_alerts/container_rules.yaml", {
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_job_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "job-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "job-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/job_alerts/job_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/job_alerts/job_rules.yaml", {
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_node_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "node-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "node-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/node_alerts/node_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/node_alerts/node_rules.yaml", {
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_nodepool_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "nodepool-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "nodepool-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/nodepool_alerts/nodepool_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/nodepool_alerts/nodepool_rules.yaml", {
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_pod_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "pod-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "pod-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/pod_alerts/pod_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/pod_alerts/pod_rules.yaml", {
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_prometheus_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "prometheus-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "prometheus-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/prometheus_alerts/prometheus_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/prometheus_alerts/prometheus_rules.yaml", {
prometheus_pvc_name = var.prometheus_pvc_name
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_coredns_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "coredns-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "coredns-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/coredns_alerts/coredns_rules.yaml"
}
}
"spec" = yamldecode(file("${path.module}/prometheus_rules/coredns_alerts/coredns_rules.yaml"))
}
}
resource "kubernetes_manifest" "prometheusrule_pvc_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "pvc-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "pvc-alerts" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/pvc_alerts/pvc_rules.yaml"
}
}
"spec" = yamldecode(templatefile("${path.module}/prometheus_rules/pvc_alerts/pvc_rules.yaml", {
runbook_base_url = local.runbook_base_url
}))
}
}
resource "kubernetes_manifest" "prometheusrule_heartbeat_alerts" {
count = var.enable_prometheusrules ? 1 : 0
manifest = {
"apiVersion" = "monitoring.coreos.com/v1"
"kind" = "PrometheusRule"
"metadata" = {
"name" = "heartbeat-alerts"
"namespace" = var.helm_namespace
"labels" = merge(local.common_labels, { "app.kubernetes.io/name" = "heartbeat-alerts" }, { "evaluated-by" = "prometheus" })
"annotations" = {
"rules-definition" = "${local.rules_base_path}/prometheus_heartbeat_alerts/prometheus_heartbeat_rules.yaml"
}
}
"spec" = yamldecode(file("${path.module}/prometheus_rules/prometheus_heartbeat_alerts/prometheus_heartbeat_rules.yaml"))
}
}