Repository navigation
Expand file tree
/
Copy pathClusterPool.workbook
More file actions
316 lines (316 loc) · 17.8 KB
/
Copy pathClusterPool.workbook
File metadata and controls
316 lines (316 loc) · 17.8 KB
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
{
"version": "Notebook/1.0",
"items": [
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "1ba6ec3b-e5db-4d8f-ba92-809f57a8062f",
"version": "KqlParameterItem/1.0",
"name": "timeRange",
"label": "Time Range",
"type": 4,
"description": "Filter data by time range",
"isRequired": true,
"value": {
"durationMs": 3600000
},
"typeSettings": {
"selectableValues": [
{
"durationMs": 900000
},
{
"durationMs": 3600000
},
{
"durationMs": 43200000
},
{
"durationMs": 86400000
},
{
"durationMs": 259200000
},
{
"durationMs": 604800000
},
{
"durationMs": 2592000000
}
],
"allowCustom": true
},
"timeContext": {
"durationMs": 86400000
},
"timeContextFromParameter": "timeRange"
},
{
"id": "925255b6-8c03-447c-aa94-f2c2b8b68a8b",
"version": "KqlParameterItem/1.0",
"name": "nameIdMapping",
"label": "Name ID Mapping",
"type": 1,
"description": "Mapping between cluster name and agent pool ID (passing in as notebook parameter from portal)",
"isRequired": true,
"isHiddenWhenLocked": true,
"timeContext": {
"durationMs": 0
},
"timeContextFromParameter": "timeRange"
},
{
"id": "eaa275f4-b2b4-40be-a008-a99f80b2f04b",
"version": "KqlParameterItem/1.0",
"name": "clusterName",
"label": "Cluster Name",
"type": 2,
"description": "Select desired cluster from this cluster pool",
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"query": "let mapping = datatable(guid:string, name:string) [ {nameIdMapping} ]; \r\n\r\nKubeNodeInventory \r\n| extend labels=parse_json(Labels)\r\n| extend guid=tostring(['labels'][0]['agentpool'])\r\n| join mapping on guid\r\n| distinct guid, name\r\n| extend clusterName = iff(name == \"\", guid, name)\r\n| project guid, clusterName",
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"showDefault": false
},
"timeContext": {
"durationMs": 0
},
"timeContextFromParameter": "timeRange",
"defaultValue": "value::all",
"queryType": 0,
"resourceType": "microsoft.containerservice/managedclusters"
}
],
"style": "above",
"queryType": 0,
"resourceType": "microsoft.containerservice/managedclusters"
},
"name": "parameters - 0 - Copy"
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"items": [
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"items": [
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let trendBinSize = case(\r\n {timeRange:end}-{timeRange:start} <= 12h, 1m, \r\n {timeRange:end}-{timeRange:start} > 12h and {timeRange:end}-{timeRange:start} <= 24h, 5m,\r\n {timeRange:end}-{timeRange:start} > 24h and {timeRange:end}-{timeRange:start} <= 3d, 10m, \r\n {timeRange:end}-{timeRange:start} > 3d and {timeRange:end}-{timeRange:start} <= 5d, 30m,\r\n 1h);\r\nlet materializedPerfData =\r\nPerf \r\n| where ObjectName == 'K8SNode'\r\n| summarize arg_max(TimeGenerated, *) by CounterName, Computer, bin(TimeGenerated, trendBinSize) \r\n| where CounterName == 'cpuAllocatableNanoCores' or CounterName == 'cpuUsageNanoCores'// or CounterName == 'memoryRssBytes' or CounterName == 'memoryCapacityBytes' \r\n| project TimeGenerated, Computer, CounterName, CounterValue\r\n| summarize StoredValue = max(CounterValue) by Computer, CounterName, bin(TimeGenerated, trendBinSize);\r\n\r\nKubeNodeInventory\r\n| extend labels=parse_json(Labels)\r\n| extend agentpool=tostring(['labels'][0]['agentpool'])\r\n| where agentpool in ({clusterName})\r\n| summarize arg_max(TimeGenerated, *) by Computer, bin(TimeGenerated, trendBinSize) \r\n| join( \r\nmaterializedPerfData \r\n| where CounterName == 'cpuAllocatableNanoCores' or CounterName == 'memoryCapacityBytes'\r\n| project Computer, CounterName = iif(CounterName == 'cpuAllocatableNanoCores', 'cpu', 'memory'), CapacityValue = StoredValue, TimeGenerated \r\n) on Computer, TimeGenerated \r\n| join kind=inner( \r\nmaterializedPerfData \r\n| where CounterName == 'cpuUsageNanoCores' or CounterName == 'memoryRssBytes' \r\n| project Computer, CounterName = iif(CounterName == 'cpuUsageNanoCores', 'cpu', 'memory'), UsageValue = StoredValue, TimeGenerated \r\n) on Computer, CounterName, TimeGenerated \r\n| project Computer, CounterName, TimeGenerated, UsagePercent = UsageValue * 100.0 / CapacityValue",
"size": 0,
"aggregation": 5,
"title": "Node CPU Utilization %",
"timeContext": {
"durationMs": 2592000000
},
"timeContextFromParameter": "timeRange",
"queryType": 0,
"resourceType": "microsoft.containerservice/managedclusters",
"visualization": "timechart",
"gridSettings": {
"filter": true,
"sortBy": [
{
"itemKey": "TimeGenerated",
"sortOrder": 1
}
]
},
"sortBy": [
{
"itemKey": "TimeGenerated",
"sortOrder": 1
}
],
"chartSettings": {
"showLegend": true,
"ySettings": {
"numberFormatSettings": {
"unit": 1,
"options": {
"style": "decimal",
"useGrouping": true,
"maximumSignificantDigits": 3
}
}
}
}
},
"name": "node_cpu_utilization_percent_query"
}
]
},
"customWidth": "50",
"name": "node_cpu_group",
"styleSettings": {
"margin": "10",
"padding": "10",
"maxWidth": "50",
"showBorder": true
}
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"items": [
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let trendBinSize = case(\r\n {timeRange:end}-{timeRange:start} <= 12h, 1m, \r\n {timeRange:end}-{timeRange:start} > 12h and {timeRange:end}-{timeRange:start} <= 24h, 5m,\r\n {timeRange:end}-{timeRange:start} > 24h and {timeRange:end}-{timeRange:start} <= 3d, 10m, \r\n {timeRange:end}-{timeRange:start} > 3d and {timeRange:end}-{timeRange:start} <= 5d, 30m,\r\n 1h);\r\nlet materializedPerfData =\r\nPerf \r\n| where ObjectName == 'K8SNode'\r\n| summarize arg_max(TimeGenerated, *) by CounterName, Computer, bin(TimeGenerated, trendBinSize) \r\n| where CounterName == 'memoryRssBytes' or CounterName == 'memoryCapacityBytes' \r\n| project TimeGenerated, Computer, CounterName, CounterValue\r\n| summarize StoredValue = max(CounterValue) by Computer, CounterName, bin(TimeGenerated, trendBinSize);\r\n\r\nKubeNodeInventory \r\n| extend labels=parse_json(Labels)\r\n| extend agentpool=tostring(['labels'][0]['agentpool'])\r\n| where agentpool in ({clusterName})\r\n| summarize arg_max(TimeGenerated, *) by Computer, bin(TimeGenerated, trendBinSize) \r\n| join( \r\nmaterializedPerfData \r\n| where CounterName == 'cpuAllocatableNanoCores' or CounterName == 'memoryCapacityBytes'\r\n| project Computer, CounterName = iif(CounterName == 'cpuAllocatableNanoCores', 'cpu', 'memory'), CapacityValue = StoredValue, TimeGenerated \r\n) on Computer, TimeGenerated \r\n| join kind=inner( \r\nmaterializedPerfData \r\n| where CounterName == 'cpuUsageNanoCores' or CounterName == 'memoryRssBytes' \r\n| project Computer, CounterName = iif(CounterName == 'cpuUsageNanoCores', 'cpu', 'memory'), UsageValue = StoredValue, TimeGenerated \r\n) on Computer, CounterName, TimeGenerated \r\n| project Computer, CounterName, TimeGenerated, UsagePercent = UsageValue * 100.0 / CapacityValue",
"size": 0,
"aggregation": 5,
"title": "Node Memory Utilization %",
"timeContext": {
"durationMs": 2592000000
},
"timeContextFromParameter": "timeRange",
"queryType": 0,
"resourceType": "microsoft.containerservice/managedclusters",
"visualization": "timechart",
"chartSettings": {
"yAxis": [
"UsagePercent"
],
"showLegend": true,
"ySettings": {
"numberFormatSettings": {
"unit": 1,
"options": {
"style": "decimal",
"useGrouping": true,
"maximumSignificantDigits": 3
}
}
}
}
},
"name": "node_memory_utilization_percent_query"
}
]
},
"customWidth": "50",
"name": "node_memory_group",
"styleSettings": {
"margin": "10",
"padding": "10",
"maxWidth": "50",
"showBorder": true
}
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"items": [
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let trendBinSize = case(\r\n {timeRange:end}-{timeRange:start} <= 12h, 1m, \r\n {timeRange:end}-{timeRange:start} > 12h and {timeRange:end}-{timeRange:start} <= 24h, 5m,\r\n {timeRange:end}-{timeRange:start} > 24h and {timeRange:end}-{timeRange:start} <= 3d, 10m, \r\n {timeRange:end}-{timeRange:start} > 3d and {timeRange:end}-{timeRange:start} <= 5d, 30m,\r\n 1h);\r\nlet rawData = \r\nKubeNodeInventory \r\n| extend labels=parse_json(Labels)\r\n| extend agentpool=tostring(['labels'][0]['agentpool'])\r\n| where agentpool in ({clusterName})\r\n| distinct ClusterId, TimeGenerated \r\n| summarize ClusterSnapshotCount = count() by Timestamp = bin(TimeGenerated, trendBinSize), ClusterId \r\n| join hint.strategy=broadcast ( \r\n KubeNodeInventory\r\n | extend labels = parse_json(Labels)\r\n | extend agentpool=tostring(['labels'][0]['agentpool'])\r\n | where agentpool in ({clusterName})\r\n | summarize TotalCount = count(), ReadyCount = sumif(1, Status contains ('Ready')) by ClusterId, Timestamp = bin(TimeGenerated, trendBinSize), agentpool\r\n | extend NotReadyCount = TotalCount - ReadyCount \r\n ) on ClusterId, Timestamp \r\n| project ClusterId, Timestamp, agentpool, \r\nTotalCount = todouble(TotalCount) / ClusterSnapshotCount, \r\nReadyCount = todouble(ReadyCount) / ClusterSnapshotCount, \r\nNotReadyCount = todouble(NotReadyCount) / ClusterSnapshotCount; \r\n\r\nrawData \r\n| order by Timestamp asc \r\n",
"size": 0,
"aggregation": 5,
"title": "Node Count",
"timeContext": {
"durationMs": 2592000000
},
"timeContextFromParameter": "timeRange",
"queryType": 0,
"resourceType": "microsoft.containerservice/managedclusters",
"visualization": "timechart",
"gridSettings": {
"filter": true
},
"chartSettings": {
"showLegend": true
}
},
"name": "node_count_query"
}
]
},
"customWidth": "50",
"name": "node_count_group",
"styleSettings": {
"margin": "10",
"padding": "10",
"maxWidth": "50",
"showBorder": true
}
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"items": [
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let trendBinSize = case(\r\n {timeRange:end}-{timeRange:start} <= 12h, 1m, \r\n {timeRange:end}-{timeRange:start} > 12h and {timeRange:end}-{timeRange:start} <= 24h, 5m,\r\n {timeRange:end}-{timeRange:start} > 24h and {timeRange:end}-{timeRange:start} <= 3d, 10m, \r\n {timeRange:end}-{timeRange:start} > 3d and {timeRange:end}-{timeRange:start} <= 5d, 30m,\r\n 1h); \r\nlet raw=\r\nKubeNodeInventory\r\n| extend labels = parse_json(Labels)\r\n| extend agentpool=tostring(['labels'][0]['agentpool'])\r\n| where agentpool in ({clusterName})\r\n| project Computer, Cluster = agentpool\r\n| distinct Computer, Cluster\r\n| join kind=inner ( \r\n KubePodInventory\r\n | project Name, Namespace, ClusterPool=ClusterName, PodIp, PodUid, Computer, PodStatus, TimeGenerated\r\n | distinct Name, Namespace, ClusterPool, PodIp, PodUid, Computer, PodStatus, TimeGenerated\r\n) on Computer;\r\n\r\nraw \r\n| distinct TimeGenerated, Namespace, Cluster \r\n| summarize ClusterSnapshotCount = count() by bin(TimeGenerated, trendBinSize), Namespace, Cluster \r\n| join hint.strategy=broadcast ( \r\nraw\r\n| summarize PodStatus=any(PodStatus) by TimeGenerated, PodUid, Namespace, Cluster \r\n| summarize Total = count(), \r\nPending = sumif(1, PodStatus =~ 'Pending'), \r\nRunning = sumif(1, PodStatus =~ 'Running'), \r\nSucceeded = sumif(1, PodStatus =~ 'Succeeded'), \r\nFailed = sumif(1, PodStatus =~ 'Failed'), \r\nTerminating = sumif(1, PodStatus =~ 'Terminating') \r\nby Namespace, Cluster, bin(TimeGenerated, trendBinSize) \r\n) on Namespace, Cluster, TimeGenerated\r\n| extend Unknown = Total - Pending - Running - Succeeded - Failed - Terminating \r\n| project Namespace, Cluster, Timestamp = TimeGenerated, \r\nTotal = todouble(Total) / ClusterSnapshotCount, \r\nPending = todouble(Pending) / ClusterSnapshotCount, \r\nRunning = todouble(Running) / ClusterSnapshotCount, \r\nSucceeded = todouble(Succeeded) / ClusterSnapshotCount, \r\nFailed = todouble(Failed) / ClusterSnapshotCount, \r\nTerminating = todouble(Terminating) / ClusterSnapshotCount, \r\nUnknown = todouble(Unknown) / ClusterSnapshotCount",
"size": 0,
"aggregation": 5,
"title": "Active Pod Count",
"timeContext": {
"durationMs": 2592000000
},
"timeContextFromParameter": "timeRange",
"queryType": 0,
"resourceType": "microsoft.containerservice/managedclusters",
"visualization": "timechart",
"gridSettings": {
"filter": true
},
"tileSettings": {
"showBorder": false
},
"graphSettings": {
"type": 0
},
"chartSettings": {
"showLegend": true
}
},
"name": "active_pod_count_query"
}
]
},
"customWidth": "50",
"name": "active_pod_group",
"styleSettings": {
"margin": "10",
"padding": "10",
"maxWidth": "50",
"showBorder": true
}
}
]
},
"name": "clusterpoolOverview",
"styleSettings": {
"showBorder": true
}
}
],
"fallbackResourceIds": [],
"$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}