-
Notifications
You must be signed in to change notification settings - Fork 7
/
04_dashboard_kube_apiserver.tf
336 lines (297 loc) · 11.3 KB
/
04_dashboard_kube_apiserver.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
##################
### Dashboards ###
##################
# Dashboard - Kube API Server
resource "newrelic_one_dashboard" "kube_apiserver" {
name = "K8s | ${var.cluster_name} | Kube API Server"
page {
name = "Kube API Server"
# Page Description
widget_markdown {
title = "Page Description"
row = 1
column = 1
height = 3
width = 4
text = "## Kube API Server\nTo be able to visualize every widget properly, Prometheus should be able to scrape the following resources:\n- Nodes Endpoints\n- Node Exporter\n- cAdvisor\n- Kube State Metrics\n- Kube API Server\n\n**Remark**: If the API server is not running as a pod but as a service on the controlplane nodes, the widgets for the corresponding node and containers will not be populated."
}
# Node Capacities
widget_table {
title = "Node Capacities"
row = 1
column = 5
height = 3
width = 4
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT uniqueCount(cpu) AS 'CPU (cores)', max(node_memory_MemTotal_bytes)/1000/1000/1000 AS 'MEM (GB)'
WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter'
AND k8s.node.name IN ({{nodes}}) FACET k8s.node.name
EOF
}
}
# Node up statuses
widget_line {
title = "Node up statuses"
row = 1
column = 9
height = 3
width = 4
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT latest(up) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}'
AND service.name = 'kubernetes-nodes' AND k8s.node.name IN ({{nodes}}) FACET k8s.node.name TIMESERIES
EOF
}
}
# Pod (Running)
widget_billboard {
title = "Pod (Running)"
row = 4
column = 1
height = 2
width = 3
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM (
FROM Metric SELECT latest(kube_pod_status_phase) AS `phase` WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND k8s.container.name = 'kube-state-metrics' AND phase = 'Running'
AND pod IN (
FROM Metric SELECT uniques(pod) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}'
AND service.name = 'kubernetes-nodes' AND pod LIKE 'kube-apiserver-%' AND k8s.node.name IN ({{nodes}}) LIMIT MAX
) FACET pod LIMIT MAX) SELECT sum(`phase`)
EOF
}
}
# Pod (Pending)
widget_billboard {
title = "Pod (Pending)"
row = 4
column = 4
height = 2
width = 3
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM (
FROM Metric SELECT latest(kube_pod_status_phase) AS `phase` WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND k8s.container.name = 'kube-state-metrics' AND phase = 'Pending'
AND pod IN (
FROM Metric SELECT uniques(pod) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}'
AND service.name = 'kubernetes-nodes' AND pod LIKE 'kube-apiserver-%' AND k8s.node.name IN ({{nodes}}) LIMIT MAX
) FACET pod LIMIT MAX) SELECT sum(`phase`)
EOF
}
}
# Pod (Failed)
widget_billboard {
title = "Pod (Failed)"
row = 4
column = 7
height = 2
width = 3
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM (
FROM Metric SELECT latest(kube_pod_status_phase) AS `phase` WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND k8s.container.name = 'kube-state-metrics' AND phase = 'Failed'
AND pod IN (
FROM Metric SELECT uniques(pod) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}'
AND service.name = 'kubernetes-nodes' AND pod LIKE 'kube-apiserver-%' AND k8s.node.name IN ({{nodes}}) LIMIT MAX
) FACET pod LIMIT MAX) SELECT sum(`phase`)
EOF
}
}
# Pod (Unknown)
widget_billboard {
title = "Pod (Unknown)"
row = 4
column = 10
height = 2
width = 3
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM (
FROM Metric SELECT latest(kube_pod_status_phase) AS `phase` WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND k8s.container.name = 'kube-state-metrics' AND phase = 'Unknown'
AND pod IN (
FROM Metric SELECT uniques(pod) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}'
AND service.name = 'kubernetes-nodes' AND pod LIKE 'kube-apiserver-%' AND k8s.node.name IN ({{nodes}}) LIMIT MAX
) FACET pod LIMIT MAX) SELECT sum(`phase`)
EOF
}
}
# Container CPU Usage per Pod (mcores)
widget_area {
title = "Container CPU Usage per Pod (mcores)"
row = 7
column = 1
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT rate(sum(container_cpu_usage_seconds_total), 1 second)*1000
WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}'
AND service.name = 'kubernetes-nodes-cadvisor' AND k8s.node.name IN ({{nodes}}) AND container IS NOT NULL
AND pod LIKE 'kube-apiserver-%' FACET pod, container TIMESERIES AUTO
EOF
}
}
# Container MEM Usage per Pod (bytes)
widget_area {
title = "Container MEM Usage per Pod (bytes)"
row = 7
column = 7
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT average(container_memory_working_set_bytes)
WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}'
AND service.name = 'kubernetes-nodes-cadvisor' AND k8s.node.name IN ({{nodes}}) AND container IS NOT NULL
AND pod IS NOT NULL AND pod LIKE 'kube-apiserver-%' FACET pod, container TIMESERIES AUTO
EOF
}
}
# Overall latency histogram (seconds)
widget_histogram {
title = "Overall latency histogram (seconds)"
row = 10
column = 1
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT histogram(apiserver_request_duration_seconds) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers'
EOF
}
}
# Average latency (seconds)
widget_line {
title = "Average latency (seconds)"
row = 10
column = 7
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT average(apiserver_request_duration_seconds) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers' TIMESERIES AUTO
EOF
}
}
# Throughput per HTTP status code (rpm)
widget_line {
title = "Throughput per HTTP status code (rpm)"
row = 13
column = 1
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT rate(sum(apiserver_request_total), 1 minute) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers' FACET code TIMESERIES AUTO
EOF
}
}
# Throughput per HTTP request type (rpm)
widget_line {
title = "Throughput per HTTP request type (rpm)"
row = 13
column = 7
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT rate(sum(apiserver_request_total), 1 minute) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers' FACET verb TIMESERIES AUTO
EOF
}
}
# Rate of additions handled by the workqueue (rpm)
widget_line {
title = "Rate of additions handled by the workqueue (rpm)"
row = 16
column = 1
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT rate(sum(workqueue_adds_total), 1 minute) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers' TIMESERIES AUTO
EOF
}
}
# Max length of workqueue
widget_line {
title = "Max length of workqueue"
row = 16
column = 7
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT max(workqueue_depth) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers' TIMESERIES AUTO
EOF
}
}
# Rate of requests being processed by request kind (rpm)
widget_line {
title = "Rate of requests being processed by request kind (rpm)"
row = 19
column = 1
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT rate(sum(apiserver_current_inflight_requests), 1 minute) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers' FACET request_kind TIMESERIES AUTO
EOF
}
}
# Rate of dropped requests (rpm)
widget_line {
title = "Rate of dropped requests (rpm)"
row = 19
column = 7
height = 3
width = 6
nrql_query {
account_id = var.NEW_RELIC_ACCOUNT_ID
query = <<EOF
FROM Metric SELECT rate(sum(apiserver_dropped_request), 1 minute) WHERE instrumentation.provider = 'opentelemetry'
AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-apiservers' TIMESERIES AUTO
EOF
}
}
}
# Nodes
variable {
name = "nodes"
title = "Nodes"
type = "nrql"
default_values = ["*"]
replacement_strategy = "default"
is_multi_selection = true
nrql_query {
account_ids = [var.NEW_RELIC_ACCOUNT_ID]
query = "FROM Metric SELECT uniques(k8s.node.name) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-nodes' AND pod LIKE 'kube-apiserver-%' LIMIT MAX"
}
}
}