forked from mspnp/aks-baseline-regulated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster-stamp.json
2436 lines (2425 loc) · 168 KB
/
cluster-stamp.json
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.1.0",
"parameters": {
"targetVnetResourceId": {
"type": "string",
"minLength": 79,
"metadata": {
"description": "The regional network spoke VNet Resource ID that the cluster will be joined to"
}
},
"clusterAdminAadGroupObjectId": {
"type": "string",
"metadata": {
"description": "Azure AD Group in the identified tenant that will be granted the highly privileged cluster-admin role."
}
},
"k8sControlPlaneAuthorizationTenantId": {
"type": "string",
"metadata": {
"description": "Your AKS control plane Cluster API authentication tenant"
}
},
"appGatewayListenerCertificate": {
"type": "string",
"metadata": {
"description": "The certificate data for app gateway TLS termination. It is base64"
}
},
"aksIngressControllerCertificate": {
"type": "string",
"metadata": {
"description": "The base 64 encoded AKS Ingress Controller public certificate (as .crt or .cer) to be stored in Azure Key Vault as secret and referenced by Azure Application Gateway as a trusted root certificate."
}
},
"location": {
"defaultValue": "eastus2",
"type": "string",
"allowedValues": [
"australiaeast",
"canadacentral",
"centralus",
"eastus",
"eastus2",
"westus2",
"francecentral",
"germanywestcentral",
"northeurope",
"southafricanorth",
"southcentralus",
"uksouth",
"westeurope",
"japaneast",
"southeastasia"
],
"metadata": {
"description": "AKS Service, Node Pools, and supporting services (KeyVault, App Gateway, etc) region. This needs to be the same region as the vnet provided in these parameters."
}
},
"geoRedundancyLocation": {
"defaultValue": "centralus",
"type": "string",
"allowedValues": [
"australiasoutheast",
"canadaeast",
"eastus2",
"westus",
"centralus",
"westcentralus",
"francesouth",
"germanynorth",
"westeurope",
"ukwest",
"northeurope",
"japanwest",
"southafricawest",
"northcentralus",
"eastasia",
"eastus",
"westus2",
"francecentral",
"uksouth",
"japaneast",
"southeastasia"
],
"metadata": {
"description": "For Azure resources that support native geo-redunancy, provide the location the redundant service will have its secondary. Should be different than the location parameter and ideally should be a paired region - https://docs.microsoft.com/azure/best-practices-availability-paired-regions. This region does not need to support availability zones."
}
},
"jumpBoxImageResourceId": {
"type": "string",
"minLength": 70,
"metadata": {
"description": "The Azure resource ID of a VM image that will be used for the jump box."
}
},
"jumpBoxCloudInitAsBase64": {
"type": "string",
"minLength": 100,
"metadata": {
"description": "A cloud init file (starting with #cloud-config) as a base 64 encoded string used to perform image customization on the jump box VMs. Used for user-management in this context."
}
}
},
"variables": {
"kubernetesVersion": "1.21.2",
"networkContributorRole": "[concat(subscription().Id, '/providers/Microsoft.Authorization/roleDefinitions/4d97b98b-1d4f-4787-a291-c67834d212e7')]",
"monitoringMetricsPublisherRole": "[concat(subscription().Id, '/providers/Microsoft.Authorization/roleDefinitions/3913510d-42f4-4e42-8a64-420c390055eb')]",
"acrPullRole": "[concat(subscription().Id, '/providers/Microsoft.Authorization/roleDefinitions/7f951dda-4ed3-4680-a7ca-43fe172d538d')]",
"dnsZoneContributorRole": "[concat(subscription().id, '/providers/Microsoft.Authorization/roleDefinitions/b12aa53e-6015-4669-85d0-8515ebb3ae7f')]",
"managedIdentityOperatorRole": "[concat(subscription().Id, '/providers/Microsoft.Authorization/roleDefinitions/f1a07417-d97a-45cb-824c-7a7467783830')]",
"subRgUniqueString": "[uniqueString('aks', subscription().subscriptionId, resourceGroup().id)]",
"nodeResourceGroupName": "[concat('rg-', variables('clusterName'), '-nodepools')]",
"clusterName": "[concat('aks-', variables('subRgUniqueString'))]",
"logAnalyticsWorkspaceName": "[concat('la-', variables('clusterName'))]",
"containerInsightsSolutionName": "[concat('ContainerInsights(', variables('logAnalyticsWorkspaceName'),')')]",
"vmInsightsSolutionName": "[concat('VMInsights(', variables('logAnalyticsWorkspaceName'),')')]",
"securityCenterSolutionName": "[concat('SecurityInsights(', variables('logAnalyticsWorkspaceName'),')')]",
"defaultAcrName": "[concat('acraks', variables('subRgUniqueString'))]",
"vNetResourceGroup": "[split(parameters('targetVnetResourceId'),'/')[4]]",
"vnetName": "[split(parameters('targetVnetResourceId'),'/')[8]]",
"vnetSystemNodePoolSubnetResourceId": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-cluster-systemnodepool')]",
"vnetInScopeNodePoolSubnetResourceId": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-cluster-inscopenodepools')]",
"vnetPrivateLinkSubnetResourceId": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-privatelinkendpoints')]",
"vnetAcrBuildSubnetResourceId": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-management-acragents')]",
"vnetOutOfScopeNodePoolSubnetResourceId": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-cluster-outofscopenodepools')]",
"vnetIngressServicesSubnetResourceId": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-cluster-ingressservices')]",
"vnetManagementOpsSubnetResourceId": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-management-ops')]",
"agwName": "[concat('apw-', variables('clusterName'))]",
"apwResourceId": "[resourceId('Microsoft.Network/applicationGateways', variables('agwName'))]",
"jumpBoxDefaultAdminUserName": "[uniqueString(variables('clusterName'), resourceGroup().id)]",
"clusterControlPlaneIdentityName": "[concat('mi-', variables('clusterName'), '-controlplane')]",
"keyVaultName": "[concat('kv-', variables('clusterName'))]",
"policyResourceIdAKSLinuxRestrictive": "/providers/Microsoft.Authorization/policySetDefinitions/42b8ef37-b724-4e24-bbc8-7a7708edfe00",
"policyResourceIdEnforceHttpsIngress": "/providers/Microsoft.Authorization/policyDefinitions/1a5b4dca-0b6f-4cf5-907c-56316bc1bf3d",
"policyResourceIdEnforceInternalLoadBalancers": "/providers/Microsoft.Authorization/policyDefinitions/3fc4dc25-5baf-40d8-9b05-7fe74c1bc64e",
"policyResourceIdRoRootFilesystem": "/providers/Microsoft.Authorization/policyDefinitions/df49d893-a74c-421d-bc95-c663042e5b80",
"policyResourceIdEnforceResourceLimits": "/providers/Microsoft.Authorization/policyDefinitions/e345eecc-fa47-480f-9e88-67dcc122b164",
"policyResourceIdEnforceImageSource": "/providers/Microsoft.Authorization/policyDefinitions/febd0533-8e55-448f-b837-bd0e06f16469",
"policyResourceIdBlockDefaultNamespace": "/providers/Microsoft.Authorization/policyDefinitions/9f061a12-e40d-4183-a00e-171812443373",
"policyResourceIdApprovedContainerPortsOnly": "/providers/Microsoft.Authorization/policyDefinitions/440b515e-a580-421e-abeb-b159a61ddcbc",
"policyResourceIdApprovedServicePortsOnly": "/providers/Microsoft.Authorization/policyDefinitions/233a2a17-77ca-4fb1-9b6b-69223d272a44",
"policyResourceIdMustUseSpecifiedLabels": "/providers/Microsoft.Authorization/policyDefinitions/46592696-4c7b-4bf3-9e45-6c2763bdc0a6",
"policyResourceIdMustUseTheseExternalIps": "/providers/Microsoft.Authorization/policyDefinitions/d46c275d-1680-448d-b2ec-e495a3b6cc89",
"policyResourceIdMustNotAutomountApiCreds": "/providers/Microsoft.Authorization/policyDefinitions/423dd1ba-798e-40e4-9c4d-b6902674b423",
"policyAssignmentNameAKSLinuxRestrictive": "[guid(variables('policyResourceIdAKSLinuxRestrictive'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameEnforceHttpsIngress": "[guid(variables('policyResourceIdEnforceHttpsIngress'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameEnforceInternalLoadBalancers": "[guid(variables('policyResourceIdEnforceInternalLoadBalancers'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameRoRootFilesystem": "[guid(variables('policyResourceIdRoRootFilesystem'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameEnforceResourceLimits": "[guid(variables('policyResourceIdEnforceResourceLimits'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameEnforceImageSource": "[guid(variables('policyResourceIdEnforceImageSource'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameBlockDefaultNamespace": "[guid(variables('policyResourceIdBlockDefaultNamespace'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameApprovedContainerPortsOnly": "[guid(variables('policyResourceIdApprovedContainerPortsOnly'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameApprovedServicePortsOnly": "[guid(variables('policyResourceIdApprovedServicePortsOnly'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameMustUseSpecifiedLabels": "[guid(variables('policyResourceIdMustUseSpecifiedLabels'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameMustUseTheseExternalIps": "[guid(variables('policyResourceIdMustUseTheseExternalIps'), resourceGroup().name, variables('clusterName'))]",
"policyAssignmentNameMustNotAutomountApiCreds": "[guid(variables('policyResourceIdMustNotAutomountApiCreds'), resourceGroup().name, variables('clusterName'))]",
"aksSecurityCenterWorkbookData": "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"## AKS Security\\n\"},\"name\":\"text - 2\"},{\"type\":9,\"content\":{\"version\":\"KqlParameterItem/1.0\",\"crossComponentResources\":[\"{workspaces}\"],\"parameters\":[{\"id\":\"311d3728-7f8a-4b16-8a34-097d099323d5\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"subscription\",\"label\":\"Subscription\",\"type\":6,\"isRequired\":true,\"multiSelect\":true,\"quote\":\"'\",\"delimiter\":\",\",\"value\":[],\"typeSettings\":{\"additionalResourceOptions\":[],\"includeAll\":false,\"showDefault\":false}},{\"id\":\"3a56d260-4fb9-46d6-b121-cea854104c91\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"workspaces\",\"label\":\"Workspaces\",\"type\":5,\"isRequired\":true,\"multiSelect\":true,\"quote\":\"'\",\"delimiter\":\",\",\"query\":\"where type =~ 'microsoft.operationalinsights/workspaces'\\r\\n| where strcat('/subscriptions/',subscriptionId) in ({subscription})\\r\\n| project id\",\"crossComponentResources\":[\"{subscription}\"],\"typeSettings\":{\"additionalResourceOptions\":[\"value::all\"]},\"queryType\":1,\"resourceType\":\"microsoft.resourcegraph/resources\",\"value\":[\"value::all\"]},{\"id\":\"9615cea6-c661-470a-b4ae-1aab8ae6f448\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"clustername\",\"label\":\"Cluster name\",\"type\":5,\"isRequired\":true,\"multiSelect\":true,\"quote\":\"'\",\"delimiter\":\",\",\"query\":\"where type == \\\"microsoft.containerservice/managedclusters\\\"\\r\\n| where strcat('/subscriptions/',subscriptionId) in ({subscription})\\r\\n| distinct tolower(id)\",\"crossComponentResources\":[\"{subscription}\"],\"value\":[\"value::all\"],\"typeSettings\":{\"resourceTypeFilter\":{\"microsoft.containerservice/managedclusters\":true},\"additionalResourceOptions\":[\"value::all\"],\"showDefault\":false},\"timeContext\":{\"durationMs\":86400000},\"queryType\":1,\"resourceType\":\"microsoft.resourcegraph/resources\"},{\"id\":\"236c00ec-1493-4e60-927a-a18b8b120cd5\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"timeframe\",\"label\":\"Time range\",\"type\":4,\"description\":\"Time\",\"isRequired\":true,\"value\":{\"durationMs\":172800000},\"typeSettings\":{\"selectableValues\":[{\"durationMs\":300000},{\"durationMs\":900000},{\"durationMs\":1800000},{\"durationMs\":3600000},{\"durationMs\":14400000},{\"durationMs\":43200000},{\"durationMs\":86400000},{\"durationMs\":172800000},{\"durationMs\":259200000},{\"durationMs\":604800000},{\"durationMs\":1209600000},{\"durationMs\":2419200000},{\"durationMs\":2592000000},{\"durationMs\":5184000000},{\"durationMs\":7776000000}],\"allowCustom\":true},\"timeContext\":{\"durationMs\":86400000}},{\"id\":\"bf0a3e4f-fff9-450c-b9d3-c8c1dded9787\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"nodeRgDetails\",\"type\":1,\"query\":\"where type == \\\"microsoft.containerservice/managedclusters\\\"\\r\\n| where tolower(id) in ({clustername})\\r\\n| project nodeRG = properties.nodeResourceGroup, subscriptionId, id = toupper(id)\\r\\n| project nodeRgDetails = strcat('\\\"', nodeRG, \\\";\\\", subscriptionId, \\\";\\\", id, '\\\"')\",\"crossComponentResources\":[\"value::all\"],\"isHiddenWhenLocked\":true,\"timeContext\":{\"durationMs\":86400000},\"queryType\":1,\"resourceType\":\"microsoft.resourcegraph/resources\"},{\"id\":\"df53126c-c40f-43d5-b99f-97ee3785c086\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"diagnosticClusters\",\"type\":1,\"query\":\"union withsource=_TableName *\\r\\n| where _TableName == \\\"AzureDiagnostics\\\" and Category == \\\"kube-audit\\\"\\r\\n| summarize diagnosticClusters = dcount(ResourceId)\\r\\n| project isDiagnosticCluster = iff(diagnosticClusters > 0, \\\"yes\\\", \\\"no\\\")\",\"crossComponentResources\":[\"{workspaces}\"],\"isHiddenWhenLocked\":true,\"timeContext\":{\"durationMs\":172800000},\"timeContextFromParameter\":\"timeframe\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\"}],\"style\":\"pills\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\"},\"name\":\"parameters - 3\"},{\"type\":11,\"content\":{\"version\":\"LinkItem/1.0\",\"style\":\"tabs\",\"links\":[{\"id\":\"07cf87dc-8234-47db-850d-ec41b2687b2a\",\"cellValue\":\"mainTab\",\"linkTarget\":\"parameter\",\"linkLabel\":\"Azure Defender for Kubernetes\",\"subTarget\":\"alerts\",\"preText\":\"\",\"style\":\"link\"},{\"id\":\"44033ee6-d83e-4253-a732-c258ef1da545\",\"cellValue\":\"mainTab\",\"linkTarget\":\"parameter\",\"linkLabel\":\"Analytics over Diagnostic logs\",\"subTarget\":\"diagnostics\",\"style\":\"link\"}]},\"name\":\"links - 22\"},{\"type\":12,\"content\":{\"version\":\"NotebookGroup/1.0\",\"groupType\":\"editable\",\"items\":[{\"type\":1,\"content\":{\"json\":\"## Azure Defender for AKS coverage\"},\"name\":\"text - 10\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"datatable (Event:string)\\r\\n [\\\"AKS Workbook\\\"]\\r\\n| extend cluster = (strcat(\\\"[\\\", \\\"{clustername}\\\", \\\"]\\\"))\\r\\n| extend cluster = todynamic(replace(\\\"'\\\", '\\\"', cluster))\\r\\n| mvexpand cluster\\r\\n| extend subscriptionId = extract(@\\\"/subscriptions/([^/]+)\\\", 1, tostring(cluster))\\r\\n| summarize AksClusters = count() by subscriptionId, DefenderForAks = 0\\r\\n| union\\r\\n(\\r\\nsecurityresources\\r\\n| where type =~ \\\"microsoft.security/pricings\\\"\\r\\n| where name == \\\"KubernetesService\\\"\\r\\n| project DefenderForAks = iif(properties.pricingTier == 'Standard', 1, 0), AksClusters = 0, subscriptionId\\r\\n)\\r\\n| summarize AksClusters = sum(AksClusters), DefenderForAks = sum(DefenderForAks) by subscriptionId\\r\\n| project Subscription = strcat('/subscriptions/', subscriptionId), [\\\"AKS clusters\\\"] = AksClusters, ['Defender for AKS'] = iif(DefenderForAks > 0,'yes','no'), ['Onboard Azure Defender'] = iif(DefenderForAks > 0, '', 'https://ms.portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/26')\\r\\n| order by ['Defender for AKS'] asc\",\"size\":0,\"queryType\":1,\"resourceType\":\"microsoft.resourcegraph/resources\",\"crossComponentResources\":[\"{subscription}\"],\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"Defender for AKS\",\"formatter\":18,\"formatOptions\":{\"thresholdsOptions\":\"icons\",\"thresholdsGrid\":[{\"operator\":\"==\",\"thresholdValue\":\"no\",\"representation\":\"4\",\"text\":\"\"},{\"operator\":\"Default\",\"thresholdValue\":null,\"representation\":\"success\",\"text\":\"\"}]}},{\"columnMatch\":\"Onboard Azure Defender\",\"formatter\":7,\"formatOptions\":{\"linkTarget\":\"Url\",\"linkLabel\":\"\"}}]}},\"customWidth\":\"66\",\"name\":\"query - 9\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"datatable (Event:string)\\r\\n [\\\"AKS Workbook\\\"]\\r\\n| extend cluster = (strcat(\\\"[\\\", \\\"{clustername}\\\", \\\"]\\\"))\\r\\n| extend cluster = todynamic(replace(\\\"'\\\", '\\\"', cluster))\\r\\n| mvexpand cluster\\r\\n| extend subscriptionId = extract(@\\\"/subscriptions/([^/]+)\\\", 1, tostring(cluster))\\r\\n| summarize AksClusters = count() by subscriptionId, DefenderForAks = 0\\r\\n| union\\r\\n(\\r\\nsecurityresources\\r\\n| where type =~ \\\"microsoft.security/pricings\\\"\\r\\n| where name == \\\"KubernetesService\\\"\\r\\n| project DefenderForAks = iif(properties.pricingTier == 'Standard', 1, 0), AksClusters = 0, subscriptionId\\r\\n)\\r\\n| summarize AksClusters = sum(AksClusters), DefenderForAks = sum(DefenderForAks) by subscriptionId\\r\\n| project Subscription = 1, ['Defender for AKS'] = iif(DefenderForAks > 0,'Protected by Azure Defender','Not protected by Azure Defender')\",\"size\":0,\"queryType\":1,\"resourceType\":\"microsoft.resourcegraph/resources\",\"crossComponentResources\":[\"{subscription}\"],\"visualization\":\"piechart\"},\"customWidth\":\"33\",\"name\":\"query - 11\"},{\"type\":1,\"content\":{\"json\":\"### AKS alerts overview\"},\"name\":\"text - 21\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType startswith \\\"AKS_\\\"\\r\\n| project image = tostring(todynamic(ExtendedProperties)[\\\"Container image\\\"]), AlertType\\r\\n| where image != \\\"\\\"\\r\\n| summarize AlertTypes = dcount(AlertType) by image\\r\\n| where AlertTypes > 1\\r\\n//| render piechart \\r\\n\",\"size\":4,\"title\":\"Images with multiple alerts\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"tiles\",\"tileSettings\":{\"showBorder\":false,\"titleContent\":{\"columnMatch\":\"image\",\"formatter\":1},\"leftContent\":{\"columnMatch\":\"AlertTypes\",\"formatter\":12,\"formatOptions\":{\"palette\":\"auto\"},\"numberFormat\":{\"unit\":17,\"options\":{\"maximumSignificantDigits\":3,\"maximumFractionDigits\":2}}}}},\"customWidth\":\"33\",\"name\":\"query - 12\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType startswith \\\"AKS_\\\"\\r\\n| project AlertType, name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, ResourceId)\\r\\n| summarize AlertTypes = dcount(AlertType) by name\\r\\n| where AlertTypes > 1\\r\\n\",\"size\":4,\"title\":\"Clusters with multiple alert types\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"tiles\",\"tileSettings\":{\"showBorder\":false,\"titleContent\":{\"columnMatch\":\"name\",\"formatter\":1},\"leftContent\":{\"columnMatch\":\"AlertTypes\",\"formatter\":12,\"formatOptions\":{\"palette\":\"auto\"},\"numberFormat\":{\"unit\":17,\"options\":{\"maximumSignificantDigits\":3,\"maximumFractionDigits\":2}}}}},\"customWidth\":\"33\",\"name\":\"query - 12 - Copy\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType startswith \\\"AKS_\\\"\\r\\n| project AlertType, name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, ResourceId)\\r\\n| summarize count() by name\\r\\n\\r\\n\",\"size\":4,\"title\":\"Alerts triggered by cluster\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"tiles\",\"tileSettings\":{\"showBorder\":false,\"titleContent\":{\"columnMatch\":\"name\",\"formatter\":1},\"leftContent\":{\"columnMatch\":\"count_\",\"formatter\":12,\"formatOptions\":{\"palette\":\"auto\"},\"numberFormat\":{\"unit\":17,\"options\":{\"maximumSignificantDigits\":3,\"maximumFractionDigits\":2}}}}},\"customWidth\":\"33\",\"name\":\"query - 12 - Copy - Copy\"},{\"type\":1,\"content\":{\"json\":\"### Seucirty alerts details\\r\\n\\r\\nTo filter, press on the severities below.\\r\\nYou can also filter based on a specific resource.\"},\"name\":\"text - 18\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert\\r\\n| where TimeGenerated {timeframe}\\r\\n| extend rg = extract(@\\\"/resourcegroups/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend sub = extract(@\\\"/subscriptions/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend nodesDetailsArr = todynamic('{nodeRgDetails}')\\r\\n| mv-expand singleNodeDetails = nodesDetailsArr\\r\\n| extend singleNodeArr = split(singleNodeDetails, \\\";\\\")\\r\\n| where tolower(singleNodeArr[0]) == rg and tolower(singleNodeArr[1]) == sub\\r\\n| project AlertSeverity\\r\\n| union\\r\\n(\\r\\nSecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType startswith \\\"AKS_\\\"\\r\\n| project AlertSeverity\\r\\n)\\r\\n| summarize count() by AlertSeverity\",\"size\":0,\"title\":\"Alerts by severity\",\"exportMultipleValues\":true,\"exportedParameters\":[{\"fieldName\":\"AlertSeverity\",\"parameterName\":\"severity\",\"parameterType\":1,\"quote\":\"\"}],\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"tiles\",\"tileSettings\":{\"showBorder\":false,\"titleContent\":{\"columnMatch\":\"AlertSeverity\",\"formatter\":1},\"leftContent\":{\"columnMatch\":\"count_\",\"formatter\":12,\"formatOptions\":{\"palette\":\"auto\"},\"numberFormat\":{\"unit\":17,\"options\":{\"maximumSignificantDigits\":3,\"maximumFractionDigits\":2}}}}},\"customWidth\":\"11\",\"name\":\"Alerts by severity\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert\\r\\n| where TimeGenerated {timeframe}\\r\\n| where \\\"{severity}\\\" has AlertSeverity or isempty(\\\"{severity}\\\")\\r\\n| extend rg = extract(@\\\"/resourcegroups/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend sub = extract(@\\\"/subscriptions/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend nodesDetailsArr = todynamic('{nodeRgDetails}')\\r\\n| mv-expand singleNodeDetails = nodesDetailsArr\\r\\n| extend singleNodeArr = split(singleNodeDetails, \\\";\\\")\\r\\n| where tolower(singleNodeArr[0]) == rg and tolower(singleNodeArr[1]) == sub\\r\\n| project ResourceId\\r\\n| union\\r\\n(\\r\\nSecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where \\\"{severity}\\\" has AlertSeverity or isempty(\\\"{severity}\\\")\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType startswith \\\"AKS_\\\"\\r\\n| project ResourceId\\r\\n)\\r\\n| summarize Alerts = count() by ResourceId\\r\\n| order by Alerts desc\\r\\n| limit 10\",\"size\":0,\"title\":\"Resources with most alerts\",\"exportFieldName\":\"ResourceId\",\"exportParameterName\":\"selectedResource\",\"exportDefaultValue\":\"not_selected\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"Alerts\",\"formatter\":4,\"formatOptions\":{\"palette\":\"red\"}}]}},\"customWidth\":\"22\",\"name\":\"Resources with most alerts\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"\\r\\nSecurityAlert\\r\\n| where TimeGenerated {timeframe}\\r\\n| where \\\"{severity}\\\" has AlertSeverity or isempty(\\\"{severity}\\\")\\r\\n| extend rg = extract(@\\\"/resourcegroups/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend sub = extract(@\\\"/subscriptions/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend nodesDetailsArr = todynamic('{nodeRgDetails}')\\r\\n| mv-expand singleNodeDetails = nodesDetailsArr\\r\\n| extend singleNodeArr = split(singleNodeDetails, \\\";\\\")\\r\\n| where tolower(singleNodeArr[0]) == rg and tolower(singleNodeArr[1]) == sub\\r\\n| extend AlertResourceType = \\\"VM alerts\\\"\\r\\n| union\\r\\n(\\r\\nSecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where \\\"{severity}\\\" has AlertSeverity or isempty(\\\"{severity}\\\")\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType startswith \\\"AKS_\\\"\\r\\n| extend AlertResourceType = \\\"Cluster alerts\\\"\\r\\n)\\r\\n| summarize Alerts = count() by bin(TimeGenerated, {timeframe:grain}), AlertResourceType\",\"size\":0,\"title\":\"Alerts over time\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"timechart\"},\"customWidth\":\"66\",\"name\":\"Alerts over time\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert\\r\\n| where TimeGenerated {timeframe}\\r\\n| where \\\"{severity}\\\" has AlertSeverity or isempty(\\\"{severity}\\\")\\r\\n| extend rg = extract(@\\\"/resourcegroups/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend sub = extract(@\\\"/subscriptions/([^/]+)\\\", 1, tolower(ResourceId))\\r\\n| extend nodesDetailsArr = todynamic('{nodeRgDetails}')\\r\\n| mv-expand singleNodeDetails = nodesDetailsArr\\r\\n| extend singleNodeArr = split(singleNodeDetails, \\\";\\\")\\r\\n| where tolower(singleNodeArr[0]) == rg and tolower(singleNodeArr[1]) == sub\\r\\n| where tolower(ResourceId) == tolower(\\\"{selectedResource}\\\") or \\\"{selectedResource}\\\" == \\\"not_selected\\\"\\r\\n| project [\\\"Resource name\\\"] = ResourceId, TimeGenerated, AlertSeverity, [\\\"AKS cluster\\\"] = toupper(singleNodeArr[2]), DisplayName, AlertLink\\r\\n| union\\r\\n(\\r\\nSecurityAlert\\r\\n| where TimeGenerated {timeframe}\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where \\\"{severity}\\\" has AlertSeverity or isempty(\\\"{severity}\\\")\\r\\n| where AlertType startswith \\\"AKS_\\\"\\r\\n| where tolower(ResourceId) == tolower(\\\"{selectedResource}\\\") or \\\"{selectedResource}\\\" == \\\"not_selected\\\"\\r\\n| project [\\\"Resource name\\\"] = ResourceId, TimeGenerated, AlertSeverity, [\\\"AKS cluster\\\"] = ResourceId, DisplayName, AlertLink\\r\\n)\\r\\n| order by TimeGenerated asc\",\"size\":0,\"title\":\"Azure Defender alerts\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"AlertLink\",\"formatter\":7,\"formatOptions\":{\"linkTarget\":\"Url\",\"linkLabel\":\"Go to alert \"}}],\"filter\":true},\"sortBy\":[]},\"name\":\"Azure Defender alerts\",\"styleSettings\":{\"showBorder\":true}}]},\"conditionalVisibility\":{\"parameterName\":\"mainTab\",\"comparison\":\"isEqualTo\",\"value\":\"alerts\"},\"name\":\"Defender Alerts\"},{\"type\":12,\"content\":{\"version\":\"NotebookGroup/1.0\",\"groupType\":\"editable\",\"items\":[{\"type\":1,\"content\":{\"json\":\"## Diagnostic logs coverage\"},\"name\":\"text - 15\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=_TableName *\\r\\n| where _TableName == \\\"AzureDiagnostics\\\" and Category == \\\"kube-audit\\\"\\r\\n| summarize count() by ResourceId = tolower(ResourceId)\\r\\n| summarize logsClusters = make_set(ResourceId)\\r\\n| extend selectedClusters = \\\"[{clustername}]\\\"\\r\\n| extend selectedClusters = replace(\\\"'\\\", '\\\"', selectedClusters)\\r\\n| extend selectedClusters = todynamic(selectedClusters)\\r\\n| mv-expand clusterId = selectedClusters\\r\\n| project clusterId = toupper(tostring(clusterId)), [\\\"Diagnostic logs\\\"] = (logsClusters has tostring(clusterId))\\r\\n| extend [\\\"Diagnostic settings\\\"] = iff([\\\"Diagnostic logs\\\"] == false, strcat(\\\"https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource\\\", clusterId, \\\"/diagnostics\\\"), \\\"\\\")\\r\\n\",\"size\":0,\"timeContext\":{\"durationMs\":172800000},\"timeContextFromParameter\":\"timeframe\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"Diagnostic logs\",\"formatter\":18,\"formatOptions\":{\"thresholdsOptions\":\"icons\",\"thresholdsGrid\":[{\"operator\":\"==\",\"thresholdValue\":\"false\",\"representation\":\"critical\",\"text\":\"\"},{\"operator\":\"Default\",\"thresholdValue\":null,\"representation\":\"success\",\"text\":\"\"}]}},{\"columnMatch\":\"Diagnostic settings\",\"formatter\":7,\"formatOptions\":{\"linkTarget\":\"Url\"}}],\"filter\":true,\"sortBy\":[{\"itemKey\":\"$gen_thresholds_Diagnostic logs_1\",\"sortOrder\":2}]},\"sortBy\":[{\"itemKey\":\"$gen_thresholds_Diagnostic logs_1\",\"sortOrder\":2}]},\"customWidth\":\"66\",\"name\":\"query - 14\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=_TableName *\\r\\n| where _TableName == \\\"AzureDiagnostics\\\" and Category == \\\"kube-audit\\\"\\r\\n| summarize count() by ResourceId = tolower(ResourceId)\\r\\n| summarize logsClusters = make_set(ResourceId)\\r\\n| extend selectedClusters = \\\"[{clustername}]\\\"\\r\\n| extend selectedClusters = replace(\\\"'\\\", '\\\"', selectedClusters)\\r\\n| extend selectedClusters = todynamic(selectedClusters)\\r\\n| mv-expand clusterId = selectedClusters\\r\\n| project clusterId = toupper(tostring(clusterId)), hasDiagnosticLogs = (logsClusters has tostring(clusterId))\\r\\n| summarize [\\\"number of clusters\\\"] = count() by hasDiagnosticLogs\\r\\n| extend hasDiagnosticLogs = iff(hasDiagnosticLogs == true, \\\"Clusters with Diagnostic logs\\\", \\\"Clusters without Diagnostic logs\\\")\\r\\n\",\"size\":0,\"timeContext\":{\"durationMs\":172800000},\"timeContextFromParameter\":\"timeframe\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"piechart\"},\"customWidth\":\"33\",\"name\":\"query - 17\"},{\"type\":12,\"content\":{\"version\":\"NotebookGroup/1.0\",\"groupType\":\"editable\",\"items\":[{\"type\":1,\"content\":{\"json\":\"## Cluster operations\"},\"name\":\"text - 16\"},{\"type\":11,\"content\":{\"version\":\"LinkItem/1.0\",\"style\":\"tabs\",\"links\":[{\"id\":\"3f616701-fd4b-482c-aff1-a85414daa05c\",\"cellValue\":\"dispalyedGraph\",\"linkTarget\":\"parameter\",\"linkLabel\":\"Masterclient operations\",\"subTarget\":\"masterclient\",\"preText\":\"\",\"style\":\"link\"},{\"id\":\"e6fa55f1-7d57-4f5e-8e83-429740853731\",\"cellValue\":\"dispalyedGraph\",\"linkTarget\":\"parameter\",\"linkLabel\":\"Pod creation operations\",\"subTarget\":\"podCreation\",\"style\":\"link\"},{\"id\":\"f4c46251-0090-4ca3-a81c-0686bff3ff35\",\"cellValue\":\"dispalyedGraph\",\"linkTarget\":\"parameter\",\"linkLabel\":\"Secret get\\\\list operations\",\"subTarget\":\"secretOperation\",\"style\":\"link\"}]},\"name\":\"links - 11\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"AzureDiagnostics \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where Category == \\\"kube-audit\\\"\\r\\n| where log_s has \\\"masterclient\\\"\\r\\n| project TimeGenerated, parse_json(log_s), ResourceId\\r\\n| project TimeGenerated, ResourceId, username = tostring(log_s[\\\"user\\\"].username)\\r\\n| where username == \\\"masterclient\\\"\\r\\n| extend name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, ResourceId)\\r\\n| summarize count() by name, bin(TimeGenerated, 1h)\",\"size\":0,\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"timechart\",\"tileSettings\":{\"showBorder\":false,\"titleContent\":{\"columnMatch\":\"name\",\"formatter\":1},\"leftContent\":{\"columnMatch\":\"count_\",\"formatter\":12,\"formatOptions\":{\"palette\":\"auto\"},\"numberFormat\":{\"unit\":17,\"options\":{\"maximumSignificantDigits\":3,\"maximumFractionDigits\":2}}}},\"chartSettings\":{\"yAxis\":[\"count_\"]}},\"conditionalVisibility\":{\"parameterName\":\"dispalyedGraph\",\"comparison\":\"isEqualTo\",\"value\":\"masterclient\"},\"name\":\"Masterclient operations\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"AzureDiagnostics\\r\\n| where Category == \\\"kube-audit\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where log_s has \\\"pods\\\"\\r\\n| project TimeGenerated, parse_json(log_s), ResourceId\\r\\n| project AzureResourceId = ResourceId, TimeGenerated,\\r\\n RequestURI = tostring(log_s[\\\"requestURI\\\"]),\\r\\n Verb = tostring(log_s[\\\"verb\\\"]),\\r\\n ObjectRef = log_s[\\\"objectRef\\\"],\\r\\n ResponseStatus = log_s[\\\"responseStatus\\\"]\\r\\n//Main query\\r\\n| where ObjectRef.resource == \\\"pods\\\" and Verb == \\\"create\\\" and ResponseStatus.code startswith \\\"20\\\"\\r\\n and RequestURI endswith \\\"/pods\\\"\\r\\n| extend name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, AzureResourceId)\\r\\n| summarize count() by name, bin(TimeGenerated, 1h)\",\"size\":0,\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"timechart\"},\"conditionalVisibility\":{\"parameterName\":\"dispalyedGraph\",\"comparison\":\"isEqualTo\",\"value\":\"podCreation\"},\"name\":\"pods creation\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"AzureDiagnostics\\r\\n| where Category == \\\"kube-audit\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where log_s has \\\"secrets\\\"\\r\\n| project TimeGenerated, parse_json(log_s), ResourceId\\r\\n| project AzureResourceId = ResourceId, TimeGenerated,\\r\\n RequestURI = tostring(log_s[\\\"requestURI\\\"]),\\r\\n Verb = tostring(log_s[\\\"verb\\\"]),\\r\\n ObjectRef = log_s[\\\"objectRef\\\"],\\r\\n ResponseStatus = log_s[\\\"responseStatus\\\"]\\r\\n//Main query\\r\\n| where ObjectRef.resource == \\\"secrets\\\" and (Verb == \\\"list\\\" or Verb == \\\"get\\\") and ResponseStatus.code startswith \\\"20\\\"\\r\\n| where ObjectRef.name != \\\"tunnelfront\\\" and ObjectRef.name != \\\"tunnelend\\\" and ObjectRef.name != \\\"kubernetes-dashboard-key-holder\\\"\\r\\n| extend name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, AzureResourceId)\\r\\n| summarize count() by name, bin(TimeGenerated, 1h)\",\"size\":0,\"timeContext\":{\"durationMs\":172800000},\"timeContextFromParameter\":\"timeframe\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"timechart\",\"gridSettings\":{\"sortBy\":[{\"itemKey\":\"count_\",\"sortOrder\":2}]},\"sortBy\":[{\"itemKey\":\"count_\",\"sortOrder\":2}]},\"conditionalVisibility\":{\"parameterName\":\"dispalyedGraph\",\"comparison\":\"isEqualTo\",\"value\":\"secretOperation\"},\"name\":\"secrets operation\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"let ascAlerts = \\nunion withsource=_TableName *\\n| where _TableName == \\\"SecurityAlert\\\"\\n| where tolower(ResourceId) in ({clustername})\\n| where TimeGenerated {timeframe}\\n| extend AlertType = column_ifexists(\\\"AlertType\\\", \\\"\\\")\\n| where AlertType == \\\"AKS_PrivilegedContainer\\\"\\n| extend ExtendedProperties = column_ifexists(\\\"ExtendedProperties\\\", todynamic(\\\"\\\"))\\n| extend ExtendedProperties = parse_json(ExtendedProperties)\\n| extend AlertLink = column_ifexists(\\\"AlertLink\\\", \\\"\\\")\\n| summarize arg_min(TimeGenerated, AlertLink) by AzureResourceId = ResourceId, name = tostring(ExtendedProperties[\\\"Pod name\\\"]), podNamespace = tostring(ExtendedProperties[\\\"Namespace\\\"])\\n;\\nlet podOperations = AzureDiagnostics\\n| where Category == \\\"kube-audit\\\"\\n| where tolower(ResourceId) in ({clustername})\\n| where TimeGenerated {timeframe}\\n| where log_s has \\\"privileged\\\"\\n| project TimeGenerated, parse_json(log_s), ResourceId\\n| project AzureResourceId = ResourceId, TimeGenerated,\\n RequestURI = tostring(log_s[\\\"requestURI\\\"]),\\n Verb = tostring(log_s[\\\"verb\\\"]),\\n ObjectRef = log_s[\\\"objectRef\\\"],\\n RequestObject = log_s[\\\"requestObject\\\"],\\n ResponseStatus = log_s[\\\"responseStatus\\\"],\\n ResponseObject = log_s[\\\"responseObject\\\"]\\n//Main query\\n| where ObjectRef.resource == \\\"pods\\\" and Verb == \\\"create\\\" and ResponseStatus.code startswith \\\"20\\\" and RequestObject has \\\"privileged\\\"\\n and RequestURI endswith \\\"/pods\\\"\\n| extend containers = RequestObject.spec.containers\\n| mvexpand containers\\n| where containers.securityContext.privileged == true\\n| summarize TimeGenerated = min(TimeGenerated) by\\n name = tostring(ResponseObject.metadata.name),\\n podNamespace = tostring(ResponseObject.metadata.namespace),\\n imageName = tostring(containers.image),\\n containerName = tostring(containers.name),\\n AzureResourceId\\n| extend id = strcat(name,\\\";\\\", AzureResourceId)\\n| extend parent = AzureResourceId\\n| join kind=leftouter (ascAlerts) on AzureResourceId, name, podNamespace\\n;\\nlet cached = materialize(podOperations)\\n;\\nlet clusters = cached | distinct AzureResourceId\\n;\\n// Main query\\ncached\\n| union\\n(\\nclusters\\n| project \\n name = AzureResourceId,\\n id = AzureResourceId,\\n parent = \\\"\\\" \\n)\\n| project-away name1, podNamespace1, TimeGenerated1\",\"size\":1,\"title\":\"Privileged containers creation\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"table\",\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"name\",\"formatter\":13,\"formatOptions\":{\"linkTarget\":null,\"showIcon\":true}},{\"columnMatch\":\"AzureResourceId\",\"formatter\":5},{\"columnMatch\":\"id\",\"formatter\":5},{\"columnMatch\":\"parent\",\"formatter\":5},{\"columnMatch\":\"AlertLink\",\"formatter\":7,\"formatOptions\":{\"linkTarget\":\"Url\",\"linkLabel\":\"\"}}],\"hierarchySettings\":{\"idColumn\":\"id\",\"parentColumn\":\"parent\",\"treeType\":0,\"expanderColumn\":\"name\"}},\"sortBy\":[]},\"customWidth\":\"66\",\"name\":\"Privileged container\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType == \\\"AKS_PrivilegedContainer\\\"\\r\\n| project name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, ResourceId)\\r\\n| summarize alert = count() by name\",\"size\":1,\"title\":\"AKS clusters with related Azure Defender alerts\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"piechart\",\"tileSettings\":{\"showBorder\":false,\"titleContent\":{\"columnMatch\":\"name\",\"formatter\":1},\"leftContent\":{\"columnMatch\":\"alert\",\"formatter\":12,\"formatOptions\":{\"palette\":\"auto\"},\"numberFormat\":{\"unit\":17,\"options\":{\"maximumSignificantDigits\":3,\"maximumFractionDigits\":2}}}},\"graphSettings\":{\"type\":0,\"topContent\":{\"columnMatch\":\"name\",\"formatter\":1},\"centerContent\":{\"columnMatch\":\"alert\",\"formatter\":1,\"numberFormat\":{\"unit\":17,\"options\":{\"maximumSignificantDigits\":3,\"maximumFractionDigits\":2}}}}},\"customWidth\":\"33\",\"name\":\"query - 7\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"let baseQuery = AzureDiagnostics \\r\\n| where Category == \\\"kube-audit\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where log_s has \\\"exec\\\"\\r\\n| project TimeGenerated, parse_json(log_s), ResourceId\\r\\n| project TimeGenerated,\\r\\n AzureResourceId = ResourceId,\\r\\n User = log_s[\\\"user\\\"],\\r\\n StageTimestamp = todatetime(log_s[\\\"stageTimestamp\\\"]),\\r\\n Timestamp = todatetime(log_s[\\\"timestamp\\\"]),\\r\\n Stage = tostring(log_s[\\\"stage\\\"]),\\r\\n RequestURI = tostring(log_s[\\\"requestURI\\\"]),\\r\\n UserAgent = tostring(log_s[\\\"userAgent\\\"]),\\r\\n Verb = tostring(log_s[\\\"verb\\\"]),\\r\\n ObjectRef = log_s[\\\"objectRef\\\"],\\r\\n ResponseStatus = log_s[\\\"responseStatus\\\"]\\r\\n| where ObjectRef.resource == \\\"pods\\\" and Verb == \\\"create\\\" and ResponseStatus.code == 101 and ObjectRef.subresource == \\\"exec\\\"\\r\\n| project operationTime = TimeGenerated,\\r\\n RequestURI,\\r\\n podName = tostring(ObjectRef.name),\\r\\n podNamespace = tostring(ObjectRef.namespace),\\r\\n username = tostring(User.username),\\r\\n AzureResourceId\\r\\n// Parse the exec command\\r\\n| extend commands = extractall(@\\\"command=([^\\\\&]*)\\\", RequestURI)\\r\\n| extend commandsStr = url_decode(strcat_array(commands, \\\" \\\"))\\r\\n| project-away ['commands'], RequestURI\\r\\n| where username != \\\"aksProblemDetector\\\"\\r\\n;\\r\\nlet cached = materialize(baseQuery);\\r\\nlet execOperations = \\r\\ncached\\r\\n| summarize operationTime = min(operationTime), numberOfPerations = count() by name = commandsStr, username, podNamespace, podName, AzureResourceId\\r\\n| extend id = name\\r\\n| extend parentId = podName\\r\\n| project id, parentId, name, operationTime, numberOfPerations, podNamespace, username, AzureResourceId\\r\\n;\\r\\nlet podOperations = \\r\\ncached\\r\\n| summarize operationTime = min(operationTime), numberOfPerations = count() by name = podName, podNamespace, AzureResourceId\\r\\n| extend id = name\\r\\n| extend parentId = AzureResourceId\\r\\n| project id, parentId, name, operationTime, numberOfPerations, podNamespace, username = \\\"\\\", AzureResourceId\\r\\n;\\r\\nlet clusterOperations = \\r\\ncached\\r\\n| summarize operationTime = min(operationTime), numberOfPerations = count() by name = AzureResourceId\\r\\n| extend id = name\\r\\n| extend parentId = \\\"\\\"\\r\\n| project id, parentId, name, operationTime, numberOfPerations, username = \\\"\\\", podNamespace = \\\"\\\", AzureResourceId = name\\r\\n;\\r\\nunion clusterOperations, podOperations, execOperations\",\"size\":1,\"title\":\"exec commands\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"table\",\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"id\",\"formatter\":5},{\"columnMatch\":\"parentId\",\"formatter\":5},{\"columnMatch\":\"numberOfPerations\",\"formatter\":4,\"formatOptions\":{\"palette\":\"blue\",\"compositeBarSettings\":{\"labelText\":\"\",\"columnSettings\":[]}}},{\"columnMatch\":\"AzureResourceId\",\"formatter\":5}],\"hierarchySettings\":{\"idColumn\":\"id\",\"parentColumn\":\"parentId\",\"treeType\":0,\"expanderColumn\":\"name\",\"expandTopLevel\":false}}},\"customWidth\":\"33\",\"name\":\"exec commands\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where AlertType == \\\"AKS_MaliciousContainerExec\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| project TimeGenerated, ResourceId, ExtendedProperties = todynamic(ExtendedProperties)\\r\\n| project TimeGenerated, ResourceId, [\\\"Pod name\\\"] = ExtendedProperties[\\\"Pod name\\\"], Command = ExtendedProperties[\\\"Command\\\"]\",\"size\":1,\"title\":\"Related Azure Defender alerts details\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"gridSettings\":{\"sortBy\":[{\"itemKey\":\"TimeGenerated\",\"sortOrder\":1}]},\"sortBy\":[{\"itemKey\":\"TimeGenerated\",\"sortOrder\":1}]},\"customWidth\":\"33\",\"name\":\"query - 9\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where AlertType == \\\"AKS_MaliciousContainerExec\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| project name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, ResourceId)\\r\\n| summarize alert = count() by name\",\"size\":1,\"title\":\"AKS clusters with related Azure Defender alerts\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"piechart\"},\"customWidth\":\"33\",\"name\":\"query - 8\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"let ascAlerts = \\r\\nunion withsource=_TableName *\\r\\n| where _TableName == \\\"SecurityAlert\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| extend AlertType = column_ifexists(\\\"AlertType\\\", \\\"\\\")\\r\\n| where AlertType == \\\"AKS_SensitiveMount\\\"\\r\\n| extend ExtendedProperties = column_ifexists(\\\"ExtendedProperties\\\", todynamic(\\\"\\\"))\\r\\n| extend ExtendedProperties = parse_json(ExtendedProperties)\\r\\n| extend AlertLink = column_ifexists(\\\"AlertLink\\\", \\\"\\\")\\r\\n| summarize arg_min(TimeGenerated, AlertLink) by AzureResourceId = ResourceId, containerName = tostring(ExtendedProperties[\\\"Container name\\\"]), mountPath = tostring(ExtendedProperties[\\\"Sensitive mount path\\\"])\\r\\n;\\r\\nlet podOperations = \\r\\nAzureDiagnostics \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where Category == \\\"kube-audit\\\"\\r\\n| where log_s has \\\"hostPath\\\"\\r\\n| project TimeGenerated, parse_json(log_s), ResourceId\\r\\n//Parsing\\r\\n| project AzureResourceId = ResourceId, TimeGenerated,\\r\\n Verb = tostring(log_s[\\\"verb\\\"]),\\r\\n ObjectRef = log_s[\\\"objectRef\\\"],\\r\\n RequestObject = log_s[\\\"requestObject\\\"],\\r\\n ResponseStatus = log_s[\\\"responseStatus\\\"],\\r\\n ResponseObject = log_s[\\\"responseObject\\\"]\\r\\n//\\r\\n//Main query\\r\\n//\\r\\n| where ObjectRef.resource == \\\"pods\\\" and Verb == \\\"create\\\" and ResponseStatus.code startswith \\\"20\\\" and RequestObject has \\\"hostPath\\\"\\r\\n| extend volumes = RequestObject.spec.volumes\\r\\n| mvexpand volumes\\r\\n| extend mountPath = volumes.hostPath.path\\r\\n| where mountPath != \\\"\\\" \\r\\n| extend container = RequestObject.spec.containers\\r\\n| mvexpand container\\r\\n| extend detectionTime = TimeGenerated\\r\\n| project detectionTime,\\r\\n podName = ResponseObject.metadata.name,\\r\\n podNamespace = ResponseObject.metadata.namespace,\\r\\n containerName = container.name,\\r\\n containerImage = container.image,\\r\\n mountPath,\\r\\n mountName = volumes.name,\\r\\n AzureResourceId,\\r\\n container\\r\\n| extend volumeMounts = container.volumeMounts\\r\\n| mv-expand volumeMounts\\r\\n| where tostring(volumeMounts.name) == tostring(mountName)\\r\\n| summarize operationTime = min(detectionTime) by AzureResourceId, name = tostring(podName),tostring(podNamespace), tostring(containerName), tostring(containerImage), tostring(mountPath), tostring(mountName)\\r\\n| extend id = strcat(name, \\\";\\\", AzureResourceId)\\r\\n| extend parent = AzureResourceId\\r\\n| join kind=leftouter (ascAlerts) on AzureResourceId, containerName, mountPath\\r\\n;\\r\\nlet cached = materialize(podOperations)\\r\\n;\\r\\nlet clusters = cached | distinct AzureResourceId\\r\\n;\\r\\n// Main query\\r\\ncached\\r\\n| union\\r\\n(\\r\\nclusters\\r\\n| project \\r\\n name = toupper(AzureResourceId),\\r\\n id = AzureResourceId,\\r\\n parent = \\\"\\\" \\r\\n)\\r\\n| project-away containerName1, mountPath1, TimeGenerated\\r\\n\",\"size\":1,\"title\":\"hostPath mount\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"AzureResourceId\",\"formatter\":5},{\"columnMatch\":\"name\",\"formatter\":13,\"formatOptions\":{\"linkTarget\":null,\"showIcon\":true}},{\"columnMatch\":\"id\",\"formatter\":5},{\"columnMatch\":\"parent\",\"formatter\":5},{\"columnMatch\":\"AzureResourceId1\",\"formatter\":5},{\"columnMatch\":\"AlertLink\",\"formatter\":7,\"formatOptions\":{\"linkTarget\":\"Url\"}}],\"hierarchySettings\":{\"idColumn\":\"id\",\"parentColumn\":\"parent\",\"treeType\":0,\"expanderColumn\":\"name\"}},\"sortBy\":[]},\"customWidth\":\"66\",\"name\":\"query - 10\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where AlertType == \\\"AKS_SensitiveMount\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| project name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, ResourceId)\\r\\n| summarize alert = count() by name\",\"size\":1,\"title\":\"AKS clusters with related Azure Defender alerts\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"piechart\",\"sortBy\":[]},\"customWidth\":\"33\",\"name\":\"query - 10\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"let bindingOper = AzureDiagnostics\\r\\n| where Category == \\\"kube-audit\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where log_s has \\\"clusterrolebindings\\\"\\r\\n| project TimeGenerated, parse_json(log_s), ResourceId\\r\\n//Parsing\\r\\n| project AzureResourceId = ResourceId, TimeGenerated,\\r\\n RequestURI = tostring(log_s[\\\"requestURI\\\"]),\\r\\n User = log_s[\\\"user\\\"],\\r\\n Verb = tostring(log_s[\\\"verb\\\"]),\\r\\n ObjectRef = log_s[\\\"objectRef\\\"],\\r\\n RequestObject = log_s[\\\"requestObject\\\"],\\r\\n ResponseStatus = log_s[\\\"responseStatus\\\"]\\r\\n| where ObjectRef.resource == \\\"clusterrolebindings\\\" and Verb == \\\"create\\\" and ResponseStatus.code startswith \\\"20\\\" and RequestObject.roleRef.name == \\\"cluster-admin\\\" \\r\\n| extend subjects = RequestObject.subjects\\r\\n| mv-expand subjects\\r\\n| project AzureResourceId, TimeGenerated, subjectName = tostring(subjects.name), subjectKind = tostring(subjects[\\\"kind\\\"]), bindingName = tostring(ObjectRef.name)\\r\\n| summarize operationTime = min(TimeGenerated) by AzureResourceId, subjectName, subjectKind, bindingName\\r\\n| extend id = strcat(subjectName, \\\";\\\", AzureResourceId)\\r\\n| extend parent = AzureResourceId\\r\\n;\\r\\nlet cached = materialize(bindingOper)\\r\\n;\\r\\nlet clusters = cached | distinct AzureResourceId\\r\\n;\\r\\n// Main query\\r\\ncached\\r\\n| union\\r\\n(\\r\\nclusters\\r\\n| project \\r\\n name = AzureResourceId,\\r\\n id = AzureResourceId,\\r\\n parent = \\\"\\\" \\r\\n)\",\"size\":1,\"title\":\"Cluster-admin binding\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"table\",\"gridSettings\":{\"formatters\":[{\"columnMatch\":\"AzureResourceId\",\"formatter\":5},{\"columnMatch\":\"id\",\"formatter\":5},{\"columnMatch\":\"parent\",\"formatter\":5},{\"columnMatch\":\"name\",\"formatter\":13,\"formatOptions\":{\"linkTarget\":null,\"showIcon\":true}}],\"hierarchySettings\":{\"idColumn\":\"id\",\"parentColumn\":\"parent\",\"treeType\":0,\"expanderColumn\":\"name\"}}},\"customWidth\":\"66\",\"name\":\"query - 5\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"SecurityAlert \\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where AlertType == \\\"AKS_ClusterAdminBinding\\\"\\r\\n| project name = extract(@\\\"/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/(.+)\\\", 1, ResourceId)\\r\\n| summarize count() by name\",\"size\":1,\"title\":\"AKS clusters with related Azure Defender alerts\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"],\"visualization\":\"piechart\"},\"customWidth\":\"33\",\"name\":\"query - 11\",\"styleSettings\":{\"showBorder\":true}},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"AzureDiagnostics\\r\\n| where Category == \\\"kube-audit\\\"\\r\\n| where tolower(ResourceId) in ({clustername})\\r\\n| where TimeGenerated {timeframe}\\r\\n| where log_s has \\\"events\\\"\\r\\n| project TimeGenerated, parse_json(log_s), ResourceId\\r\\n//Parsing\\r\\n| project AzureResourceId = ResourceId, \\r\\n TimeGenerated,\\r\\n SourceIPs = tostring(log_s[\\\"sourceIPs\\\"][0]),\\r\\n User = log_s[\\\"user\\\"],\\r\\n Verb = tostring(log_s[\\\"verb\\\"]),\\r\\n ObjectRef = log_s[\\\"objectRef\\\"],\\r\\n ResponseStatus = log_s[\\\"responseStatus\\\"]\\r\\n| where ObjectRef.resource == \\\"events\\\" and Verb == \\\"delete\\\" and ResponseStatus.code == 200\\r\\n| project TimeGenerated, AzureResourceId, username = tostring(User.username), ipAddr = tostring(SourceIPs), \\r\\n eventName = tostring(ObjectRef.name), eventNamespace = tostring(ObjectRef.namespace), status = tostring(ResponseStatus.code)\\r\\n| summarize operationTime = min(TimeGenerated), eventNames = make_set(eventName, 10) by\\r\\n AzureResourceId, \\r\\n eventNamespace,\\r\\n username,\\r\\n ipAddr\\r\\n// Format the list of the event names\\r\\n| extend eventNames = substring(eventNames, 1 , strlen(eventNames) - 2)\\r\\n| extend eventNames = replace('\\\"', \\\"\\\", eventNames)\\r\\n| extend eventNames = replace(\\\",\\\", \\\", \\\", eventNames)\",\"size\":1,\"title\":\"Delete events\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\",\"crossComponentResources\":[\"{workspaces}\"]},\"name\":\"query - 6\",\"styleSettings\":{\"showBorder\":true}}]},\"conditionalVisibility\":{\"parameterName\":\"diagnosticClusters\",\"comparison\":\"isEqualTo\",\"value\":\"yes\"},\"name\":\"diagnosticData\"},{\"type\":1,\"content\":{\"json\":\"No Diagnostic Logs data in the selected workspaces. \\r\\nTo enable Diagnostic Logs for your AKS cluster: Go to your AKS cluster --> Diagnostic settings --> Add diagnostic setting --> Select \\\"kube-audit\\\" and send the data to your workspace.\\r\\n\\r\\nGet more details here: https://docs.microsoft.com/azure/aks/view-master-logs\",\"style\":\"info\"},\"conditionalVisibility\":{\"parameterName\":\"diagnosticClusters\",\"comparison\":\"isEqualTo\",\"value\":\"no\"},\"name\":\"text - 4\"}]},\"conditionalVisibility\":{\"parameterName\":\"mainTab\",\"comparison\":\"isEqualTo\",\"value\":\"diagnostics\"},\"name\":\"diagnostics\"}],\"fromTemplateId\":\"sentinel-AksWorkbook\",\"$schema\":\"https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json\"}"
},
"resources": [
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2018-11-30",
"name": "[variables('clusterControlPlaneIdentityName')]",
"location": "[parameters('location')]",
"comments": "The control plane identity used by the cluster. Used for networking access (VNET joining and DNS updating)"
},
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2018-11-30",
"name": "mi-appgateway-frontend",
"location": "[parameters('location')]",
"comments": "User Managed Identity that App Gateway is assigned. Used for Azure Key Vault Access."
},
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2020-12-01",
"name": "vmss-jumpboxes",
"comments": "Hosts the VMs used as AKS jumpboxes. Using VMSS as a way to manage spanning fault and update domains.",
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName'))]",
"[resourceId('Microsoft.OperationsManagement/solutions', variables('vmInsightsSolutionName'))]"
],
"location": "[parameters('location')]",
"zones": ["1", "2", "3"],
"sku": {
"name": "Standard_DS1_v2",
"tier": "Standard",
"capacity": 2
},
"properties": {
"additionalCapabilities": {
"ultraSSDEnabled": false
},
"overprovision": false,
"singlePlacementGroup": true,
"upgradePolicy": {
"mode": "Automatic"
},
"zoneBalance": false,
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
},
"osProfile": {
"computerNamePrefix": "aksjmp",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"provisionVMAgent": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', variables('jumpBoxDefaultAdminUserName'), '/.ssh/authorized_keys')]",
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCcFvQl2lYPcK1tMB3Tx2R9n8a7w5MJCSef14x0ePRFr9XISWfCVCNKRLM3Al/JSlIoOVKoMsdw5farEgXkPDK5F+SKLss7whg2tohnQNQwQdXit1ZjgOXkis/uft98Cv8jDWPbhwYj+VH/Aif9rx8abfjbvwVWBGeA/OnvfVvXnr1EQfdLJgMTTh+hX/FCXCqsRkQcD91MbMCxpqk8nP6jmsxJBeLrgfOxjH8RHEdSp4fF76YsRFHCi7QOwTE/6U+DpssgQ8MTWRFRat97uTfcgzKe5MOfuZHZ++5WFBgaTr1vhmSbXteGiK7dQXOk2cLxSvKkzeaiju9Jy6hoSl5oMygUVd5fNPQ94QcqTkMxZ9tQ9vPWOHwbdLRD31Ses3IBtDV+S6ehraiXf/L/e0jRUYk8IL/J543gvhOZ0hj2sQqTj9XS2hZkstZtrB2ywrJzV5ByETUU/oF9OsysyFgnaQdyduVqEPHaqXqnJvBngqqas91plyT3tSLMez3iT0s= unused-generated-by-azure"
}
]
}
},
"customData": "[parameters('jumpBoxCloudInitAsBase64')]",
"adminUsername": "[variables('jumpBoxDefaultAdminUserName')]"
},
"storageProfile": {
"osDisk": {
"createOption": "FromImage",
"caching": "ReadOnly",
"diffDiskSettings": {
"option": "Local"
},
"osType": "Linux"
},
"imageReference": {
"id": "[parameters('jumpBoxImageResourceId')]"
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "vnet-spoke-BU0001A0005-01-nic01",
"properties": {
"primary": true,
"enableIPForwarding": false,
"enableAcceleratedNetworking": false,
"networkSecurityGroup": "[null()]",
"ipConfigurations": [
{
"name": "default",
"properties": {
"primary": true,
"privateIPAddressVersion": "IPv4",
"publicIPAddressConfiguration": "[null()]",
"subnet": {
"id": "[variables('vnetManagementOpsSubnetResourceId')]"
}
}
}
]
}
}
]
}
}
},
"resources": [
{
"type": "extensions",
"apiVersion": "2019-12-01",
"name": "OMSExtension",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'vmss-jumpboxes')]"
],
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "OmsAgentForLinux",
"typeHandlerVersion": "1.13",
"autoUpgradeMinorVersion": true,
"settings": {
"stopOnMultipleConnections": true,
"azureResourceId": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'vmss-jumpboxes')]",
"workspaceId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName')), '2020-10-01').customerId]"
},
"protectedSettings": {
"workspaceKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName')), '2020-10-01').primarySharedKey]"
}
}
},
{
"type": "extensions",
"apiVersion": "2019-12-01",
"name": "DependencyAgentLinux",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachineScaleSets', 'vmss-jumpboxes')]"
],
"properties": {
"publisher": "Microsoft.Azure.Monitoring.DependencyAgent",
"type": "DependencyAgentLinux",
"typeHandlerVersion": "9.10",
"autoUpgradeMinorVersion": true
}
}
]
},
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2018-11-30",
"name": "podmi-ingress-controller",
"location": "[parameters('location')]",
"comments": "User Managed Identity for the cluster's ingress controller pods. Used for Azure Key Vault Access.",
"resources": [
{
"type": "providers/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[concat('Microsoft.Authorization/', guid(resourceGroup().id, variables('managedIdentityOperatorRole')))]",
"comments": "Grant the AKS cluster control plane with Managed Identity Operator role permissions over the this ingress controller pod identity so that it can be assigned to the relevant nodepools.",
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))]",
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'podmi-ingress-controller')]"
],
"properties": {
"roleDefinitionId": "[variables('managedIdentityOperatorRole')]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
}
]
},
{
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2019-09-01",
"name": "[variables('keyVaultName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'mi-appgateway-frontend')]",
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'podmi-ingress-controller')]"
],
"properties": {
"accessPolicies": [
{
"tenantId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'mi-appgateway-frontend')).tenantId]",
"objectId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'mi-appgateway-frontend')).principalId]",
"permissions": {
"secrets": [
"get"
],
"certificates": [
"get"
],
"keys": []
}
},
{
"tenantId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'podmi-ingress-controller')).tenantId]",
"objectId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'podmi-ingress-controller')).principalId]",
"permissions": {
"secrets": [
"get"
],
"certificates": [
"get"
],
"keys": []
}
}
],
"sku": {
"family": "A",
"name": "standard"
},
"tenantId": "[subscription().tenantId]",
"networkAcls": {
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": []
},
"enabledForDeployment": false,
"enabledForDiskEncryption": false,
"enabledForTemplateDeployment": false,
"enableSoftDelete": true
},
"resources": [
{
"type": "secrets",
"apiVersion": "2019-09-01",
"name": "sslcert",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName') )]"
],
"properties": {
"value": "[parameters('appGatewayListenerCertificate')]",
"recoveryLevel": "Purgeable"
}
},
{
"type": "secrets",
"apiVersion": "2019-09-01",
"name": "appgw-ingress-internal-aks-ingress-contoso-com-tls",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]"
],
"properties": {
"value": "[parameters('aksIngressControllerCertificate')]",
"recoveryLevel": "Purgeable"
}
},
{
"type": "providers/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "Microsoft.Insights/default",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]",
"[resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName'))]"
],
"properties": {
"workspaceId": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName'))]",
"logs": [
{
"category": "AuditEvent",
"enabled": true
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true
}
]
}
}
]
},
{
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-11-01",
"name": "[concat('pe-', variables('keyVaultName'))]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]"
],
"properties": {
"subnet": {
"id": "[variables('vnetPrivateLinkSubnetResourceId')]"
},
"privateLinkServiceConnections": [
{
"name": "[concat('to-', variables('vnetName'))]",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]",
"groupIds": [
"vault"
]
}
}
]
},
"resources": [
{
"type": "privateDnsZoneGroups",
"apiVersion": "2020-11-01",
"name": "[concat('for-', variables('keyVaultName'))]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/privateEndpoints', concat('pe-', variables('keyVaultName')))]"
],
"properties": {
"privateDnsZoneConfigs": [
{
"name": "privatelink-akv-net",
"properties": {
"privateDnsZoneId": "[resourceId(variables('vNetResourceGroup'), 'Microsoft.Network/privateDnsZones', 'privatelink.vaultcore.azure.net')]"
}
}
]
}
}
]
},
{
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-11-01",
"name": "[concat('pe-', variables('defaultAcrName'))]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.ContainerRegistry/registries/replications', variables('defaultAcrName'), parameters('geoRedundancyLocation'))]"
],
"properties": {
"subnet": {
"id": "[variables('vnetPrivateLinkSubnetResourceId')]"
},
"privateLinkServiceConnections": [
{
"name": "[concat('to-', variables('vnetName'))]",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.ContainerRegistry/registries', variables('defaultAcrName'))]",
"groupIds": [
"registry"
]
}
}
]
},
"resources": [
{
"type": "privateDnsZoneGroups",
"apiVersion": "2020-11-01",
"name": "[concat('for-', variables('defaultAcrName'))]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/privateEndpoints', concat('pe-', variables('defaultAcrName')))]"
],
"properties": {
"privateDnsZoneConfigs": [
{
"name": "privatelink-azurecr-io",
"properties": {
"privateDnsZoneId": "[resourceId(variables('vNetResourceGroup'), 'Microsoft.Network/privateDnsZones', 'privatelink.azurecr.io')]"
}
}
]
}
}
]
},
{
"type": "Microsoft.Network/applicationGateways",
"apiVersion": "2020-11-01",
"name": "[variables('agwName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName') )]"
],
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'mi-appgateway-frontend')]": {}
}
},
"zones": [
"1",
"2",
"3"
],
"properties": {
"sku": {
"name": "WAF_v2",
"tier": "WAF_v2"
},
"sslPolicy": {
"policyType": "Custom",
"cipherSuites": [
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
],
"minProtocolVersion": "TLSv1_2"
},
"trustedRootCertificates": [
{
"name": "root-cert-wildcard-aks-ingress-contoso",
"properties": {
"keyVaultSecretId": "[concat(reference(variables('keyVaultName')).vaultUri,'secrets/appgw-ingress-internal-aks-ingress-contoso-com-tls')]"
}
}
],
"gatewayIPConfigurations": [
{
"name": "apw-ip-configuration",
"properties": {
"subnet": {
"id": "[concat(parameters('targetVnetResourceId'), '/subnets/snet-applicationgateway')]"
}
}
}
],
"frontendIPConfigurations": [
{
"name": "apw-frontend-ip-configuration",
"properties": {
"publicIPAddress": {
"id": "[resourceId(subscription().subscriptionId, variables('vNetResourceGroup'), 'Microsoft.Network/publicIpAddresses', 'pip-BU0001A0005-00')]"
}
}
}
],
"frontendPorts": [
{
"name": "apw-frontend-ports",
"properties": {
"port": 443
}
}
],
"autoscaleConfiguration": {
"minCapacity": 0,
"maxCapacity": 10
},
"webApplicationFirewallConfiguration": {
"enabled": true,
"firewallMode": "Prevention",
"ruleSetType": "OWASP",
"ruleSetVersion": "3.2",
"disabledRuleGroups": [],
"requestBodyCheck": true,
"maxRequestBodySizeInKb": 128,
"fileUploadLimitInMb": 100
},
"enableHttp2": false,
"sslCertificates": [
{
"name": "[concat(variables('agwName'), '-ssl-certificate')]",
"properties": {
"keyVaultSecretId": "[concat(reference(variables('keyVaultName')).vaultUri,'secrets/sslcert')]"
}
}
],
"probes": [
{
"name": "probe-bu0001a0005-00.aks-ingress.contoso.com",
"properties": {
"protocol": "Https",
"path": "/favicon.ico",
"interval": 30,
"timeout": 30,
"unhealthyThreshold": 3,
"pickHostNameFromBackendHttpSettings": true,
"minServers": 0,
"match": {}
}
},
{
"name": "ingress-controller",
"properties": {
"protocol": "Https",
"path": "/healthz",
"interval": 30,
"timeout": 30,
"unhealthyThreshold": 3,
"pickHostNameFromBackendHttpSettings": true,
"minServers": 0,
"match": {}
}
}
],
"backendAddressPools": [
{
"name": "bu0001a0005-00.aks-ingress.contoso.com",
"properties": {
"backendAddresses": [
{
/* This is the IP address that our ingress controller will request */
"ipAddress": "10.240.4.4"
}
]
}
}
],
"backendHttpSettingsCollection": [
{
"name": "aks-ingress-contoso-backendpool-httpsettings",
"properties": {
"port": 443,
"protocol": "Https",
"cookieBasedAffinity": "Disabled",
"hostName": "bu0001a0005-00.aks-ingress.contoso.com",
"pickHostNameFromBackendAddress": false,
"requestTimeout": 20,
"probe": {
"id": "[concat(resourceId('Microsoft.Network/applicationGateways', variables('agwName')),'/probes/probe-bu0001a0005-00.aks-ingress.contoso.com')]"
},
"trustedRootCertificates": [
{
"id": "[concat(resourceId('Microsoft.Network/applicationGateways', variables('agwName')), '/trustedRootCertificates/root-cert-wildcard-aks-ingress-contoso')]"
}
]
}
}
],
"httpListeners": [
{
"name": "listener-https",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(variables('apwResourceId'), '/frontendIPConfigurations/apw-frontend-ip-configuration')]"
},
"frontendPort": {
"id": "[concat(variables('apwResourceId'), '/frontendPorts/apw-frontend-ports')]"
},
"protocol": "Https",
"sslCertificate": {
"id": "[concat(variables('apwResourceId'), '/sslCertificates/', variables('agwName'), '-ssl-certificate')]"
},
"hostName": "bicycle.contoso.com",
"hostNames": [],
"requireServerNameIndication": true
}
}
],
"requestRoutingRules": [
{
"name": "apw-routing-rules",
"properties": {
"ruleType": "Basic",
"httpListener": {
"id": "[concat(variables('apwResourceId'), '/httpListeners/listener-https')]"
},
"backendAddressPool": {
"id": "[concat(variables('apwResourceId'), '/backendAddressPools/bu0001a0005-00.aks-ingress.contoso.com')]"
},
"backendHttpSettings": {
"id": "[concat(variables('apwResourceId'), '/backendHttpSettingsCollection/aks-ingress-contoso-backendpool-httpsettings')]"
}
}
}
]
},
"resources": [
{
"type": "/providers/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "Microsoft.Insights/default",
"dependsOn": [
"[resourceId('Microsoft.Network/applicationGateways', variables('agwName'))]",
"[resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName'))]"
],
"properties": {
"workspaceId": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName'))]",
"logs": [
{
"category": "ApplicationGatewayAccessLog",
"enabled": true
},
{
"category": "ApplicationGatewayPerformanceLog",
"enabled": true
},
{
"category": "ApplicationGatewayFirewallLog",
"enabled": true
}
]
}
}
]
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-06-01",
"name": "EnsureClusterIdentityHasRbacToSelfManagedResources",
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))]"
],
"resourceGroup": "[variables('vNetResourceGroup')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(parameters('targetVnetResourceId'), variables('dnsZoneContributorRole'), variables('clusterControlPlaneIdentityName'))]",
"scope": "[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]",
"properties": {
"roleDefinitionId": "[variables('dnsZoneContributorRole')]",
"description": "Allows cluster identity to attach custom DNS zone with Private Link information to this virtual network.",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(variables('vnetSystemNodePoolSubnetResourceId'), variables('networkContributorRole'), variables('clusterControlPlaneIdentityName'))]",
"scope": "[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'), '/subnets/', 'snet-cluster-systemnodepool')]",
"properties": {
"roleDefinitionId": "[variables('networkContributorRole')]",
"description": "Allows cluster identity to join the nodepool vmss resources to this subnet.",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(variables('vnetInScopeNodePoolSubnetResourceId'), variables('networkContributorRole'), variables('clusterControlPlaneIdentityName'))]",
"scope": "[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'), '/subnets/', 'snet-cluster-inscopenodepools')]",
"properties": {
"roleDefinitionId": "[variables('networkContributorRole')]",
"description": "Allows cluster identity to join the nodepool vmss resources to this subnet.",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(variables('vnetOutOfScopeNodePoolSubnetResourceId'), variables('networkContributorRole'), variables('clusterControlPlaneIdentityName'))]",
"scope": "[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'), '/subnets/', 'snet-cluster-outofscopenodepools')]",
"properties": {
"roleDefinitionId": "[variables('networkContributorRole')]",
"description": "Allows cluster identity to join the nodepool vmss resources to this subnet.",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(variables('vnetIngressServicesSubnetResourceId'), variables('networkContributorRole'), variables('clusterControlPlaneIdentityName'))]",
"scope": "[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'), '/subnets/', 'snet-cluster-ingressservices')]",
"properties": {
"roleDefinitionId": "[variables('networkContributorRole')]",
"description": "Allows cluster identity to join load balancers (ingress resources) to this subnet.",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(resourceId('Microsoft.Network/privateDnsZones', concat('privatelink.', parameters('location'), '.azmk8s.io')), variables('dnsZoneContributorRole'), variables('clusterControlPlaneIdentityName'))]",
"scope": "[concat('Microsoft.Network/privateDnsZones/', concat('privatelink.', parameters('location'), '.azmk8s.io'))]",
"properties": {
"roleDefinitionId": "[variables('dnsZoneContributorRole')]",
"description": "Allows cluster identity to manage zone Entries for cluster's Private Link configuration.",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('clusterControlPlaneIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
}
]
}
}
},
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2020-08-01",
"name": "[variables('logAnalyticsWorkspaceName')]",
"location": "[parameters('location')]",
"properties": {
"sku": {
"name": "PerGB2018"
},
"retentionInDays": 90,
"publicNetworkAccessForIngestion": "Enabled",
"publicNetworkAccessForQuery": "Enabled"
},
"resources": [
{
"type": "savedSearches",
"apiVersion": "2020-08-01",
"name": "AllPrometheus",
"dependsOn": [
"[concat('Microsoft.OperationalInsights/workspaces/', variables('logAnalyticsWorkspaceName'))]"
],
"properties": {
"eTag": "*",
"category": "Prometheus",
"displayName": "All collected Prometheus information",
"query": "InsightsMetrics | where Namespace == \"prometheus\"",
"version": 1
}
},
{
"type": "savedSearches",
"apiVersion": "2020-08-01",
"name": "ForbiddenReponsesOnIngress",
"dependsOn": [
"[concat('Microsoft.OperationalInsights/workspaces/', variables('logAnalyticsWorkspaceName'))]"
],
"properties": {
"eTag": "*",
"category": "Prometheus",
"displayName": "Increase number of forbidden response on the Ingress Controller",
"query": "let value = toscalar(InsightsMetrics | where Namespace == \"prometheus\" and Name == \"nginx_ingress_controller_requests\" | where parse_json(Tags).status == 403 | summarize Value = avg(Val) by bin(TimeGenerated, 5m) | summarize min = min(Value)); InsightsMetrics | where Namespace == \"prometheus\" and Name == \"nginx_ingress_controller_requests\" | where parse_json(Tags).status == 403 | summarize AggregatedValue = avg(Val)-value by bin(TimeGenerated, 5m) | order by TimeGenerated | render barchart",
"version": 1
}
},
{
"type": "savedSearches",
"apiVersion": "2020-08-01",
"name": "NodeRebootRequested",
"dependsOn": [
"[concat('Microsoft.OperationalInsights/workspaces/', variables('logAnalyticsWorkspaceName'))]"
],
"properties": {
"eTag": "*",
"category": "Prometheus",
"displayName": "Nodes reboot required by kured",
"query": "InsightsMetrics | where Namespace == \"prometheus\" and Name == \"kured_reboot_required\" | where Val > 0",
"version": 1
}
}
]
},
{
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2020-05-01-preview",
"name": "Image Imported into ACR from source other than approved Quarantine",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName'))]",
"[resourceId('Microsoft.ContainerRegistry/registries', variables('defaultAcrName'))]"
],
"properties": {
"description":"The only images we want in live/ are those that came from this ACR instance, but from the quarantine/ repository.",
"actions": [],
"criteria": {
"allOf": [
{
"operator": "GreaterThan",
"query": "ContainerRegistryRepositoryEvents\r\n| where OperationName == \"importImage\" and Repository startswith \"live/\" and MediaType !startswith strcat(_ResourceId, \"/quarantine\")",
"threshold": 0,
"timeAggregation": "Count",
"dimensions": [],
"failingPeriods": {
"minFailingPeriodsToAlert": 1,
"numberOfEvaluationPeriods": 1
},
"resourceIdColumn": ""
}
]
},
"enabled": true,
"evaluationFrequency": "PT10M",
"scopes": [
"[resourceId('Microsoft.ContainerRegistry/registries', variables('defaultAcrName'))]"
],
"severity": 3,
"windowSize": "PT10M",
"muteActionsDuration": null,
"overrideQueryTimeRange": null
}
},
{
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2020-05-01-preview",
"name": "PodFailedScheduledQuery",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkspaceName'))]",
"[resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName'))]"
],
"properties": {
"description":"Example from: https://docs.microsoft.com/azure/azure-monitor/insights/container-insights-alerts",
"actions": [],
"criteria": {
"allOf": [
{
"metricMeasureColumn": "FailedCount",
"operator": "GreaterThan",
"query": "let trendBinSize = 1m;\r\nKubePodInventory\r\n| distinct ClusterName, TimeGenerated\r\n| summarize ClusterSnapshotCount = count() by bin(TimeGenerated, trendBinSize), ClusterName\r\n| join hint.strategy=broadcast (\r\n KubePodInventory\r\n | distinct ClusterName, Computer, PodUid, TimeGenerated, PodStatus\r\n | summarize TotalCount = count(),\r\n PendingCount = sumif(1, PodStatus =~ \"Pending\"),\r\n RunningCount = sumif(1, PodStatus =~ \"Running\"),\r\n SucceededCount = sumif(1, PodStatus =~ \"Succeeded\"),\r\n FailedCount = sumif(1, PodStatus =~ \"Failed\")\r\n by ClusterName, bin(TimeGenerated, trendBinSize)\r\n )\r\n on ClusterName, TimeGenerated \r\n| extend UnknownCount = TotalCount - PendingCount - RunningCount - SucceededCount - FailedCount\r\n| project TimeGenerated,\r\n ClusterName,\r\n TotalCount = todouble(TotalCount) / ClusterSnapshotCount,\r\n PendingCount = todouble(PendingCount) / ClusterSnapshotCount,\r\n RunningCount = todouble(RunningCount) / ClusterSnapshotCount,\r\n SucceededCount = todouble(SucceededCount) / ClusterSnapshotCount,\r\n FailedCount = todouble(FailedCount) / ClusterSnapshotCount,\r\n UnknownCount = todouble(UnknownCount) / ClusterSnapshotCount\r\n",
"threshold": 3,
"timeAggregation": "Average",
"dimensions": [],
"failingPeriods": {
"minFailingPeriodsToAlert": 1,
"numberOfEvaluationPeriods": 1
},
"resourceIdColumn": ""
}
]
},
"enabled": true,
"evaluationFrequency": "PT5M",
"scopes": [
"[resourceId('Microsoft.ContainerService/managedClusters', variables('clusterName'))]"
],
"severity": 3,
"windowSize": "PT5M",
"muteActionsDuration": null,
"overrideQueryTimeRange": "P2D"
}
},
{
"type": "Microsoft.Insights/activityLogAlerts",
"apiVersion": "2017-04-01",
"name": "AllAzureAdvisorAlert",
"location": "Global",
"properties": {
"scopes": [
"[resourceGroup().id]"
],
"condition": {
"allOf": [
{
"field": "category",