Repository navigation
Expand file tree
/
Copy pathVPNGateway.workbook
More file actions
960 lines (960 loc) · 86.5 KB
/
Copy pathVPNGateway.workbook
File metadata and controls
960 lines (960 loc) · 86.5 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
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
{
"version": "Notebook/1.0",
"items": [
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"crossComponentResources": [
"{workspace}"
],
"parameters": [
{
"id": "f79d5185-6941-488e-a728-3beaec49f9d4",
"version": "KqlParameterItem/1.0",
"name": "timeInterval",
"label": "Time interval",
"type": 4,
"description": "Select time interval to get data",
"isRequired": true,
"value": {
"durationMs": 86400000
},
"typeSettings": {
"selectableValues": [
{
"durationMs": 1800000
},
{
"durationMs": 3600000
},
{
"durationMs": 43200000
},
{
"durationMs": 86400000
},
{
"durationMs": 604800000
},
{
"durationMs": 1209600000
},
{
"durationMs": 2592000000
}
],
"allowCustom": true
}
},
{
"id": "042c4aca-7514-4fe0-852a-55bf59b7f0ab",
"version": "KqlParameterItem/1.0",
"name": "timeIntervalFlowlogCheck",
"type": 1,
"description": "Time scope filter for flowlog",
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "TimeGenerated between (todatetime('{timeInterval:startISO}') .. datetime_add('day', 7, todatetime('{timeInterval:endISO}')))"
}
}
]
},
{
"id": "53f8d464-cc4e-4906-86e7-3c90800ed609",
"version": "KqlParameterItem/1.0",
"name": "timeIntervalTopologyCheck",
"type": 1,
"description": "Time scope filter for topology",
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff({timeInterval:seconds} < 86400, TimeGenerated between (datetime_add('day', -1, todatetime('{timeInterval:endISO}')) .. todatetime('{timeInterval:endISO}')), TimeGenerated between (todatetime('{timeInterval:startISO}') .. todatetime('{timeInterval:endISO}')))"
}
}
]
},
{
"version": "KqlParameterItem/1.0",
"name": "timeIntervalBothCheck",
"type": 1,
"description": "Time scope filter for flowlog and topology",
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff({timeInterval:seconds} < 86400, TimeGenerated between (datetime_add('day', -1, todatetime('{timeInterval:endISO}')) .. datetime_add('day', 7, todatetime('{timeInterval:endISO}'))), TimeGenerated between (todatetime('{timeInterval:startISO}') .. datetime_add('day', 7, todatetime('{timeInterval:endISO}'))))"
}
}
],
"id": "2789eac4-1d01-4930-9db6-e1ff84200cba"
},
{
"id": "5f59846f-1e06-4f6f-b52f-d06bb63b97fb",
"version": "KqlParameterItem/1.0",
"name": "workspace",
"label": "Log Analytics workspace",
"type": 5,
"description": "Select a workspace where Traffic Analytics is configured",
"isRequired": true,
"isGlobal": true,
"query": "Resources\r\n| where type=~ \"microsoft.network/networkwatchers/flowlogs\"\r\n| where properties.flowAnalyticsConfiguration.networkWatcherFlowAnalyticsConfiguration.enabled == true\r\n| project wsResourceId = tolower(properties.flowAnalyticsConfiguration.networkWatcherFlowAnalyticsConfiguration.workspaceResourceId)\r\n| distinct wsResourceId\r\n| project wsResourceId, wsName = tolower(split(wsResourceId, '/')[8])\r\n",
"crossComponentResources": [
"value::all"
],
"value": null,
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"timeContext": {
"durationMs": 86400000
},
"queryType": 1,
"resourceType": "microsoft.resourcegraph/resources"
},
{
"id": "8ba132ac-8838-476c-8eb2-ed42aa2aa983",
"version": "KqlParameterItem/1.0",
"name": "subscriptions",
"label": "Discovered Subscriptions",
"type": 2,
"description": "NSGs in these subscriptions are configured to send their flow logs to the selected Log Analytics workspace. Select subscriptions, to analyze traffic from those subscriptions.",
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"query": "AzureNetworkAnalytics_CL\r\n| where {timeIntervalTopologyCheck}\r\n| where SubType_s == 'StatusMessage' and ComponentType_s == 'Topology'\r\n| distinct Subscription_g, SubscriptionName_s\r\n| project Subscription_g, SubscriptionName_s, selected = 1",
"crossComponentResources": [
"{workspace}"
],
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"selectAllValue": "*",
"showDefault": false
},
"defaultValue": "value::all",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
{
"id": "2a16ef52-9f5d-459b-987e-0b75297860ad",
"version": "KqlParameterItem/1.0",
"name": "subscriptionsCheck",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{subscriptions}\" == \"'*'\", true, Subscription_g in~ ({subscriptions}))"
}
}
]
},
{
"id": "d2028f10-9c63-499c-947d-08eb9a41121d",
"version": "KqlParameterItem/1.0",
"name": "resourceGroups",
"label": "Resource groups",
"type": 2,
"description": "Traffic from the VNets in the selected resource groups, shall be analyzed. Select one or more resource groups.",
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"query": "AzureNetworkAnalytics_CL\r\n| where {timeIntervalTopologyCheck}\r\n| where SubType_s =='Topology' and ResourceType !in ('VirtualSubnetwork','VirtualNetworkGatewayConnection','RemoteGatewayConnection', 'Route','NetworkAnalytics','VirtualNetworkPeering','NetworkSecurityGroupRule','SubnetworkConnection')\r\n| where {subscriptionsCheck}\r\n| project rgName = tostring(split(Name_s,'/')[0]), Subscription_g\r\n| distinct rgName, Subscription_g\r\n| project value = rgName, label = rgName, selected = 1",
"crossComponentResources": [
"{workspace}"
],
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"selectAllValue": "*",
"showDefault": false
},
"defaultValue": "value::all",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
{
"id": "96e71097-a8c9-4b64-903c-26a51bac174c",
"version": "KqlParameterItem/1.0",
"name": "resourceGroupsCheck",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{resourceGroups}\" == \"'*'\", true, rgToCheck in~ ({resourceGroups}))"
}
}
]
},
{
"id": "282d8918-3c0c-43a0-aa36-6c14c3f5be79",
"version": "KqlParameterItem/1.0",
"name": "vnets",
"label": "VNet",
"type": 2,
"description": "Select one or more virtual networks",
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"query": "AzureNetworkAnalytics_CL\r\n| where {timeIntervalTopologyCheck}\r\n| where SubType_s =='Topology' and ResourceType == 'VirtualNetwork'\r\n| where {subscriptionsCheck}\r\n| extend rgToCheck = tostring(split(Name_s, '/')[0])\r\n| where {resourceGroupsCheck} \r\n| project vnetId = strcat(Subscription_g, '/', Name_s )\r\n| distinct vnetId\r\n| project vnetName = tostring(split(vnetId, '/')[2])\r\n| project value = vnetName, label = vnetName, selected = 1",
"crossComponentResources": [
"{workspace}"
],
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"selectAllValue": "*",
"showDefault": false
},
"defaultValue": "value::all",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
{
"id": "211ed21c-5181-4c94-9d86-edddce8e6d4b",
"version": "KqlParameterItem/1.0",
"name": "vnetsCheck",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"leftOperand": "vnets",
"operator": "is Empty",
"rightValType": "param",
"resultValType": "static",
"resultVal": "// skip"
}
},
{
"criteriaContext": {
"leftOperand": "vnets",
"operator": "==",
"rightValType": "static",
"rightVal": "*",
"resultValType": "static",
"resultVal": "// skip"
}
},
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "| where vnetToCheck in ({vnets})"
}
}
]
},
{
"id": "998ea1ee-ca40-437a-a9a9-68ad70e7221e",
"version": "KqlParameterItem/1.0",
"name": "vnet1Check",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{vnets}\" == \"'*'\", true, vnet1ToCheck in ({vnets}))"
}
}
]
},
{
"id": "ab8d7ab7-3b67-4785-9668-6d0ade5b995e",
"version": "KqlParameterItem/1.0",
"name": "vnet2Check",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{vnets}\" == \"'*'\", true, vnet2ToCheck in ({vnets}))"
}
}
]
},
{
"id": "99b8addb-cbb8-4763-8dbd-fe01c284cd5a",
"version": "KqlParameterItem/1.0",
"name": "vpnGateways",
"label": "VPN Gateway",
"type": 2,
"description": "Select one or more VPN gateways",
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"query": "AzureNetworkAnalytics_CL\r\n| where {timeIntervalTopologyCheck}\r\n| where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGateway'\r\n| where isnotempty(Subscription_g) and {subscriptionsCheck}\r\n| extend rgToCheck = split(Name_s, '/')[0]\r\n| where {resourceGroupsCheck}\r\n| where GatewayType_s == 'Vpn'\r\n| extend SubnetSpilt = split(VirtualSubnetwork_s, '/')\r\n| extend vnetToCheck = strcat(Subscription_g, '/', SubnetSpilt[0], '/', SubnetSpilt[1])\r\n{vnetsCheck}\r\n| extend GatewayName = strcat(Subscription_g, '/', Name_s)\r\n| distinct GatewayName\r\n| project value = GatewayName, label = split(GatewayName, '/')[2], selected = 1",
"crossComponentResources": [
"{workspace}"
],
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"selectAllValue": "*",
"showDefault": false
},
"defaultValue": "value::all",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
{
"id": "4d509a3d-79d4-4734-9872-538d0d287a93",
"version": "KqlParameterItem/1.0",
"name": "vpnGatewayConnections",
"label": "VPN Gateway connection",
"type": 2,
"description": "Select one or more VNet Gateway connections",
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"query": "let table1 = \r\n AzureNetworkAnalytics_CL\r\n | where {timeIntervalBothCheck}\r\n | where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection'\r\n | where isnotempty(Subscription_g) and {subscriptionsCheck}\r\n | extend rgToCheck = split(Name_s, '/')[0]\r\n | where {resourceGroupsCheck}\r\n | where ConnectionType_s in~ ('Vnet2Vnet', 'IPsec')\r\n | extend vnet1ToCheck = VirtualNetwork1_s, vnet2ToCheck = VirtualNetwork2_s\r\n | where {vnet1Check} or {vnet2Check}\r\n | extend ConnectionName = strcat(Subscription_g, '/', Name_s)\r\n | where iff(\"{vpnGateways}\" == \"'*'\", true, VirtualNetworkGateway1_s in~ ({vpnGateways}) or VirtualNetworkGateway2_s in~ ({vpnGateways}))\r\n | distinct ConnectionName;\r\nlet table2 = \r\n AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalBothCheck}\r\n | where FlowType_s == 'P2S' and ConnectionType_s == 'VpnGateway'\r\n | distinct ConnectionName_s\r\n | extend ConnectionNameSplit = split(ConnectionName_s, '/')\r\n | where iff(\"{subscriptions}\" == \"'*'\", true, tostring(ConnectionNameSplit[0]) in~ ({subscriptions}))\r\n | extend rgToCheck = tostring(ConnectionNameSplit[1])\r\n | where {resourceGroupsCheck}\r\n | project Gateway = substring(ConnectionName_s, 0, indexof_regex(ConnectionName_s, '_[^_]+$')), ConnectionName = ConnectionName_s\r\n | where iff(\"{vpnGateways}\" == \"'*'\", true, Gateway in~ ({vpnGateways}));\r\nunion kind=outer table1, table2\r\n| distinct ConnectionName\r\n| project value = ConnectionName, label = split(ConnectionName, '/')[2], selected = 1",
"crossComponentResources": [
"{workspace}"
],
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"selectAllValue": "*",
"showDefault": false
},
"defaultValue": "value::all",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"name": "parameters - 2"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "46fdbc80-975e-40ec-810b-bf7118ff3420",
"version": "KqlParameterItem/1.0",
"name": "subscription1Check",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{subscriptions}\" == \"'*'\", true, Subscription1_g in~ ({subscriptions}))"
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "c5d7e5b2-58c2-441f-9bcd-d82c38c9501c",
"version": "KqlParameterItem/1.0",
"name": "subscription2Check",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{subscriptions}\" == \"'*'\", true, Subscription2_g in~ ({subscriptions}))"
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "a3b54f25-1e18-4e33-9582-0a7d0cb600ce",
"version": "KqlParameterItem/1.0",
"name": "resourceGroup1Check",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{resourceGroups}\" == \"'*'\", true, rg1ToCheck in~ ({resourceGroups})) "
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "739e4291-4a53-46b4-8348-ce2bc4cc1ee1",
"version": "KqlParameterItem/1.0",
"name": "resourceGroup2Check",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{resourceGroups}\" == \"'*'\", true, rg2ToCheck in~ ({resourceGroups})) "
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "f31c23e9-d4e4-4c08-909c-5131d3f987a4",
"version": "KqlParameterItem/1.0",
"name": "vnet1Check",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{vnets}\" == \"'*'\", true, vnet1ToCheck in~ ({vnets})) "
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "d6fd78ee-4d6b-4cd3-9d99-896a5e080db1",
"version": "KqlParameterItem/1.0",
"name": "vnet2Check",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "iff(\"{vnets}\" == \"'*'\", true, vnet2ToCheck in~ ({vnets})) "
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "3c55b9e9-fd50-466f-a841-e06cd3a2c3d7",
"version": "KqlParameterItem/1.0",
"name": "vpnGateway1Check",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"leftOperand": "vpnGateways",
"operator": "is Empty",
"rightValType": "param",
"resultValType": "static",
"resultVal": "// skip"
}
},
{
"criteriaContext": {
"leftOperand": "vpnGateways",
"operator": "==",
"rightValType": "static",
"rightVal": "*",
"resultValType": "static",
"resultVal": "// skip"
}
},
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "| where VirtualNetworkGateway1_s in ({vpnGateways})"
}
}
]
},
{
"id": "d18419f7-77a6-4c0d-aba5-a99333bccafd",
"version": "KqlParameterItem/1.0",
"name": "vpnGatewayConnectionCheck",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"leftOperand": "vpnGatewayConnections",
"operator": "is Empty",
"rightValType": "param",
"resultValType": "static",
"resultVal": "// skip"
}
},
{
"criteriaContext": {
"leftOperand": "vpnGatewayConnections",
"operator": "==",
"rightValType": "static",
"rightVal": "*",
"resultValType": "static",
"resultVal": "// skip"
}
},
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "| where ConnectionName_s in ({vpnGatewayConnections})"
}
}
]
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"conditionalVisibility": {
"parameterName": "timeInterval",
"comparison": "isEqualTo",
"value": "never"
},
"name": "parameters - 10"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "c973b119-cf4d-462f-b450-d7e5f78add4d",
"version": "KqlParameterItem/1.0",
"name": "thousandUnit",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "K"
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "a2ca6b76-958e-4362-8fa9-937954ce8c7d",
"version": "KqlParameterItem/1.0",
"name": "millionUnit",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "M"
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "2187717d-ce29-4f0b-a3cc-b7c559f34092",
"version": "KqlParameterItem/1.0",
"name": "billionUnit",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "B"
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "fd412543-04e8-4545-bbd0-0531b02536c2",
"version": "KqlParameterItem/1.0",
"name": "trillionUnit",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "t"
}
}
],
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "6a6400a0-c770-4f09-b760-d1deaf8a4973",
"version": "KqlParameterItem/1.0",
"name": "quadrillionUnit",
"type": 1,
"isRequired": true,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "q"
}
}
],
"timeContext": {
"durationMs": 86400000
}
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"conditionalVisibility": {
"parameterName": "timeInterval",
"comparison": "isEqualTo",
"value": "never"
},
"name": "Constants"
},
{
"type": 1,
"content": {
"json": "##### Capacity utilization of selected gateway"
},
"name": "text - 10"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "AzureNetworkAnalytics_CL\r\n| where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection' and ConnectionType_s in ('Vnet2Vnet', 'IPsec')\r\n| where {timeIntervalTopologyCheck}\r\n| where isnotempty(Subscription_g) and {subscriptionsCheck}\r\n| extend rgToCheck = split(Name_s, '/')[0]\r\n| where {resourceGroupsCheck}\r\n| extend vnet1ToCheck = VirtualNetwork1_s, vnet2ToCheck = VirtualNetwork2_s\r\n| where {vnet1Check} or {vnet2Check}\r\n{vpnGateway1Check}\r\n| extend ConnectionName_s = strcat(Subscription_g, '/', Name_s)\r\n{vpnGatewayConnectionCheck}\r\n| summarize sumEgress = sum(EgressBytesTransferred_d), sumIngress = sum(IngressBytesTransferred_d)\r\nby Gateway = VirtualNetworkGateway1_s, TimeProcessed_t\r\n| sort by bin(TimeProcessed_t, 1ms) asc\r\n| extend Temp = pack(\"sumEgress\",sumEgress,\"sumIngress\",sumIngress )\r\n| mv-expand kind=array Temp\r\n| project TimeProcessed_t, Key = strcat(tostring(Temp[0]), '-', Gateway), Volume = tolong(Temp[1])",
"size": 0,
"aggregation": 5,
"showAnalytics": true,
"showExportToExcel": true,
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"visualization": "timechart",
"graphSettings": {
"type": 0,
"topContent": {
"columnMatch": "Gateway",
"formatter": 1
},
"centerContent": {
"columnMatch": "sumEgress",
"formatter": 1,
"numberFormat": {
"unit": 17,
"options": {
"maximumSignificantDigits": 3,
"maximumFractionDigits": 2
}
}
}
},
"chartSettings": {
"xAxis": "TimeProcessed_t",
"yAxis": [
"Volume"
],
"ySettings": {
"numberFormatSettings": {
"unit": 2,
"options": {
"style": "decimal",
"useGrouping": true,
"maximumFractionDigits": 2
}
}
}
}
},
"showPin": true,
"name": "query - 11"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "8a4902b7-b0a6-4949-92b4-910cef05f453",
"version": "KqlParameterItem/1.0",
"name": "sortUnit",
"label": "units in",
"type": 2,
"description": "This unit will be used to get the top 5 IPs.",
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"jsonData": "[\r\n { \"value\":\"flows\", \"label\":\"Flows\", \"selected\":true },\r\n { \"value\":\"bytes\", \"label\":\"Bytes\" },\r\n { \"value\":\"packets\", \"label\":\"Packets\"}\r\n]",
"timeContext": {
"durationMs": 86400000
}
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"name": "parameters - 3"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"crossComponentResources": [
"{workspace}"
],
"parameters": [
{
"id": "8340f941-9688-4c62-9074-543636f115cb",
"version": "KqlParameterItem/1.0",
"name": "top5Gateways",
"type": 2,
"isRequired": true,
"multiSelect": true,
"quote": "'",
"delimiter": ",",
"query": "let topVPNGatewaysS2SAndInterVNet = \r\n (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection' and ConnectionType_s in ('Vnet2Vnet', 'IPsec')\r\n | extend ConnectionName_s = strcat(Subscription_g, '/', Name_s)\r\n //\r\n | where {timeIntervalTopologyCheck}\r\n | where isnotempty(Subscription_g) and {subscriptionsCheck}\r\n | extend rgToCheck = split(Name_s, '/')[0]\r\n | where {resourceGroupsCheck}\r\n | extend vnet1ToCheck = VirtualNetwork1_s, vnet2ToCheck = VirtualNetwork2_s\r\n | where {vnet1Check} or {vnet2Check}\r\n //\r\n | project ConnectionName_s, Gateway1 = VirtualNetworkGateway1_s, Gateway2 = VirtualNetworkGateway2_s\r\n | distinct Gateway1, Gateway2, ConnectionName_s)\r\n | join kind = inner \r\n (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and {timeIntervalFlowlogCheck} and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s in ('S2S', 'InterVNet') and ConnectionType_s == 'VpnGateway')\r\n on ConnectionName_s;\r\nlet topVPNGatewaysP2S =\r\n AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and {timeIntervalFlowlogCheck} and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s == 'P2S' and ConnectionType_s == 'VpnGateway'\r\n | extend ConnectionNameSplit = split(ConnectionName_s, '/')\r\n | extend subscription1ToCheck = tostring(ConnectionNameSplit[0])\r\n | where {subscription1Check}\r\n | extend rg1ToCheck = tostring(ConnectionNameSplit[1])\r\n | where {resourceGroup1Check}\r\n {vpnGatewayConnectionCheck}\r\n | extend GatewayP2S = substring(ConnectionName_s, 0, indexof_regex(ConnectionName_s, '_[^_]+$'));\r\ntopVPNGatewaysS2SAndInterVNet\r\n| union topVPNGatewaysP2S\r\n| extend CountryOrRegion = iif(FlowType_s == 'AzurePublic', AzureRegion_s, Country_s)\r\n| extend \r\nAllowedInboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), \r\nBlockedInboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), \r\nAllowedOutboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), \r\nBlockedOutboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), \r\nAllowedInboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), \r\nBlockedInboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), \r\nAllowedOutboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0), \r\nBlockedOutboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0)\r\n| extend \r\nAllowedInboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), \r\nBlockedInboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), \r\nAllowedOutboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), \r\nBlockedOutboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), \r\nAllowedInboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), \r\nBlockedInboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), \r\nAllowedOutboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0), \r\nBlockedOutboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0)\r\n| extend FlowDirection_s = iif(FlowType_s in ('InterVNet', 'IntraVNet'), '', FlowDirection_s)\r\n| summarize \r\nAllowedInbound = sum(AllowedInFlows_d), BlockedInbound = sum(DeniedInFlows_d), \r\nAllowedOutbound = sum(AllowedOutFlows_d), BlockedOutbound = sum(DeniedOutFlows_d),\r\nAllowedInboundBytesAtSrc = sum(AllowedInboundBytesAtSrc), BlockedInboundBytesAtSrc = sum(BlockedInboundBytesAtSrc), \r\nAllowedOutboundBytesAtSrc = sum(AllowedOutboundBytesAtSrc), BlockedOutboundBytesAtSrc = sum(BlockedOutboundBytesAtSrc), \r\nAllowedInboundBytesAtDest = sum(AllowedInboundBytesAtDest), BlockedInboundBytesAtDest = sum(BlockedInboundBytesAtDest), \r\nAllowedOutboundBytesAtDest = sum(AllowedOutboundBytesAtDest), BlockedOutboundBytesAtDest = sum(BlockedOutboundBytesAtDest),\r\nAllowedInboundPacketsAtSrc = sum(AllowedInboundPacketsAtSrc), BlockedInboundPacketsAtSrc = sum(BlockedInboundPacketsAtSrc), \r\nAllowedOutboundPacketsAtSrc = sum(AllowedOutboundPacketsAtSrc), BlockedOutboundPacketsAtSrc = sum(BlockedOutboundPacketsAtSrc), \r\nAllowedInboundPacketsAtDest = sum(AllowedInboundPacketsAtDest), BlockedInboundPacketsAtDest = sum(BlockedInboundPacketsAtDest), \r\nAllowedOutboundPacketsAtDest = sum(AllowedOutboundPacketsAtDest), BlockedOutboundPacketsAtDest = sum(BlockedOutboundPacketsAtDest)\r\nby SrcIP_s, Subscription1_g, NIC1_s, DestIP_s, Subscription2_g, NIC2_s, FlowDirection_s, L4Protocol_s, DestPort_d, CountryOrRegion, Gateway1, Gateway2, GatewayP2S\r\n| extend AllowedOutbound_inferred = max_of(AllowedOutbound, AllowedInbound + BlockedInbound)\r\n| extend Outbound = AllowedOutbound_inferred + BlockedOutbound, Inbound = AllowedOutbound_inferred\r\n| extend FlowCount = max_of(Inbound, Outbound)\r\n| extend AllowedOutboundBytesAtSrc_inferred = max_of(AllowedOutboundBytesAtSrc, AllowedInboundBytesAtDest + BlockedInboundBytesAtDest)\r\n| extend AllowedOutboundBytesAtDest_inferred = max_of(AllowedOutboundBytesAtDest, AllowedInboundBytesAtSrc + BlockedInboundBytesAtSrc)\r\n| extend OutboundBytesAtSrc = AllowedOutboundBytesAtSrc_inferred + BlockedOutboundBytesAtSrc, InboundBytesAtSrc = AllowedOutboundBytesAtDest_inferred\r\n| extend OutboundBytesAtDest = AllowedOutboundBytesAtDest_inferred + BlockedOutboundBytesAtDest, InboundBytesAtDest = AllowedOutboundBytesAtSrc_inferred\r\n| extend BytesCount = max_of(OutboundBytesAtSrc, InboundBytesAtDest) + max_of(OutboundBytesAtDest, InboundBytesAtSrc)\r\n| extend AllowedOutboundPacketsAtSrc_inferred = max_of(AllowedOutboundPacketsAtSrc, AllowedInboundPacketsAtDest + BlockedInboundPacketsAtDest)\r\n| extend AllowedOutboundPacketsAtDest_inferred = max_of(AllowedOutboundPacketsAtDest, AllowedInboundPacketsAtSrc + BlockedInboundPacketsAtSrc)\r\n| extend OutboundPacketsAtSrc = AllowedOutboundPacketsAtSrc_inferred + BlockedOutboundPacketsAtSrc, InboundPacketsAtSrc = AllowedOutboundPacketsAtDest_inferred\r\n| extend OutboundPacketsAtDest = AllowedOutboundPacketsAtDest_inferred + BlockedOutboundPacketsAtDest, InboundPacketsAtDest = AllowedOutboundPacketsAtSrc_inferred\r\n| extend PacketsCount = max_of(OutboundPacketsAtSrc, InboundPacketsAtDest) + max_of(OutboundPacketsAtDest, InboundPacketsAtSrc)\r\n| mv-expand Gateway = pack_array(Gateway1, Gateway2, GatewayP2S) to typeof(string)\r\n| where isnotempty(Gateway)\r\n| where iff(\"{vpnGateways}\" == \"'*'\", true, Gateway in ({vpnGateways}))\r\n| summarize TotalTraffic = sum(iff('{sortUnit:value}' =~ 'bytes', BytesCount, iff('{sortUnit:value}' =~ 'packets', PacketsCount, tolong(FlowCount)))) by Gateway\r\n| where TotalTraffic > 0\r\n| top 5 by TotalTraffic",
"crossComponentResources": [
"{workspace}"
],
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"showDefault": false
},
"defaultValue": "value::all",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
{
"id": "a050abd6-c366-4fc9-b1aa-f309acafa79c",
"version": "KqlParameterItem/1.0",
"name": "binningTime",
"type": 2,
"isRequired": true,
"query": "datatable (id:int) [1]\r\n| project value = strcat(max_of({timeInterval:seconds}/3000, 1), 'm'), label = strcat(max_of({timeInterval:seconds}/3000, 1), 'm'), selected = 1",
"crossComponentResources": [
"{workspace}"
],
"isHiddenWhenLocked": true,
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"timeContext": {
"durationMs": 1800000
},
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
{
"id": "d8e966a3-196a-48fe-b1ef-38ef706ded39",
"version": "KqlParameterItem/1.0",
"name": "top5GatewaysTest",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"operator": "Default",
"rightValType": "param",
"resultValType": "static",
"resultVal": "'a38f78b2-f840-4628-90f8-009ec9745a16/autorg1/vnet1eusgateway', 'a38f78b2-f840-4628-90f8-009ec9745a16/s2s-test/rras-s2s-vnetgw', 'a38f78b2-f840-4628-90f8-009ec9745a16/autorg3/vnet11weugateway', 'a38f78b2-f840-4628-90f8-009ec9745a16/autorg2/vnet6wcusgateway', 'af15e575-f948-49ac-bce0-252d028e9379/canaryresourcegroup3/canaryvnet3-vpngateway'"
}
}
]
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"conditionalVisibility": {
"parameterName": "tabSelected",
"comparison": "isEqualTo",
"value": "-1"
},
"name": "parameters - 18"
},
{
"type": 1,
"content": {
"json": "##### Total traffic per VPN gateway"
},
"name": "text - 12"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let lineChartVPNGwS2SAndInterVNet =\r\n (AzureNetworkAnalytics_CL\r\n | where {timeIntervalTopologyCheck}\r\n | where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection' and ConnectionType_s in ('Vnet2Vnet', 'IPsec')\r\n | where VirtualNetworkGateway1_s in~ ({top5Gateways}) or VirtualNetworkGateway2_s in~ ({top5Gateways})\r\n | extend ConnectionName_s = strcat(Subscription_g, '/', Name_s)\r\n {vpnGatewayConnectionCheck}\r\n | distinct ConnectionName_s)\r\n | join kind = inner (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s in ('S2S', 'InterVNet') and ConnectionType_s == 'VpnGateway')\r\n on ConnectionName_s\r\n | extend CountryOrRegion = iif(FlowType_s == 'AzurePublic', AzureRegion_s, Country_s)\r\n | extend AllowedInboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), BlockedInboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), AllowedInboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), BlockedInboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0)\r\n | extend AllowedInboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), AllowedInboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0)\r\n | extend FlowDirection_s = iif(FlowType_s in ('InterVNet', 'IntraVNet'), '', FlowDirection_s)\r\n | summarize \r\n AllowedInbound = sum(AllowedInFlows_d), BlockedInbound = sum(DeniedInFlows_d), AllowedOutbound = sum(AllowedOutFlows_d), BlockedOutbound = sum(DeniedOutFlows_d),\r\n AllowedInboundBytesAtSrc = sum(AllowedInboundBytesAtSrc), BlockedInboundBytesAtSrc = sum(BlockedInboundBytesAtSrc), AllowedOutboundBytesAtSrc = sum(AllowedOutboundBytesAtSrc), BlockedOutboundBytesAtSrc = sum(BlockedOutboundBytesAtSrc), AllowedInboundBytesAtDest = sum(AllowedInboundBytesAtDest), BlockedInboundBytesAtDest = sum(BlockedInboundBytesAtDest), AllowedOutboundBytesAtDest = sum(AllowedOutboundBytesAtDest), BlockedOutboundBytesAtDest = sum(BlockedOutboundBytesAtDest),\r\n AllowedInboundPacketsAtSrc = sum(AllowedInboundPacketsAtSrc), BlockedInboundPacketsAtSrc = sum(BlockedInboundPacketsAtSrc), AllowedOutboundPacketsAtSrc = sum(AllowedOutboundPacketsAtSrc), BlockedOutboundPacketsAtSrc = sum(BlockedOutboundPacketsAtSrc), AllowedInboundPacketsAtDest = sum(AllowedInboundPacketsAtDest), BlockedInboundPacketsAtDest = sum(BlockedInboundPacketsAtDest), AllowedOutboundPacketsAtDest = sum(AllowedOutboundPacketsAtDest), BlockedOutboundPacketsAtDest = sum(BlockedOutboundPacketsAtDest)\r\n by SrcIP_s, Subscription1_g, NIC1_s, DestIP_s, Subscription2_g, NIC2_s, FlowDirection_s, L4Protocol_s, DestPort_d, CountryOrRegion, FlowStartTime_t\r\n | extend AllowedOutbound_inferred = max_of(AllowedOutbound, AllowedInbound + BlockedInbound)\r\n | extend Outbound = AllowedOutbound_inferred + BlockedOutbound, Inbound = AllowedOutbound_inferred\r\n | extend FlowCount = max_of(Inbound, Outbound)\r\n | extend AllowedOutboundBytesAtSrc_inferred = max_of(AllowedOutboundBytesAtSrc, AllowedInboundBytesAtDest + BlockedInboundBytesAtDest)\r\n | extend AllowedOutboundBytesAtDest_inferred = max_of(AllowedOutboundBytesAtDest, AllowedInboundBytesAtSrc + BlockedInboundBytesAtSrc)\r\n | extend OutboundBytesAtSrc = AllowedOutboundBytesAtSrc_inferred + BlockedOutboundBytesAtSrc, InboundBytesAtSrc = AllowedOutboundBytesAtDest_inferred\r\n | extend OutboundBytesAtDest = AllowedOutboundBytesAtDest_inferred + BlockedOutboundBytesAtDest, InboundBytesAtDest = AllowedOutboundBytesAtSrc_inferred\r\n | extend BytesCount = max_of(OutboundBytesAtSrc, InboundBytesAtDest) + max_of(OutboundBytesAtDest, InboundBytesAtSrc)\r\n | extend AllowedOutboundPacketsAtSrc_inferred = max_of(AllowedOutboundPacketsAtSrc, AllowedInboundPacketsAtDest + BlockedInboundPacketsAtDest)\r\n | extend AllowedOutboundPacketsAtDest_inferred = max_of(AllowedOutboundPacketsAtDest, AllowedInboundPacketsAtSrc + BlockedInboundPacketsAtSrc)\r\n | extend OutboundPacketsAtSrc = AllowedOutboundPacketsAtSrc_inferred + BlockedOutboundPacketsAtSrc, InboundPacketsAtSrc = AllowedOutboundPacketsAtDest_inferred\r\n | extend OutboundPacketsAtDest = AllowedOutboundPacketsAtDest_inferred + BlockedOutboundPacketsAtDest, InboundPacketsAtDest = AllowedOutboundPacketsAtSrc_inferred\r\n | extend PacketsCount = max_of(OutboundPacketsAtSrc, InboundPacketsAtDest) + max_of(OutboundPacketsAtDest, InboundPacketsAtSrc);\r\nlet lineChartVPNGwP2S =\r\n AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s == 'P2S' and ConnectionType_s == 'VpnGateway'\r\n | extend AllowedOutbound_inferred = max_of(AllowedOutFlows_d, AllowedInFlows_d + DeniedInFlows_d)\r\n | extend Outbound = AllowedOutbound_inferred + DeniedOutFlows_d, Inbound = AllowedOutbound_inferred\r\n | extend FlowCount = max_of(Inbound, Outbound)\r\n | extend AllowedInboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), BlockedInboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), AllowedInboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), BlockedInboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0)\r\n | extend AllowedOutboundBytesAtSrc_inferred = max_of(AllowedOutboundBytesAtSrc, AllowedInboundBytesAtDest + BlockedInboundBytesAtDest)\r\n | extend AllowedOutboundBytesAtDest_inferred = max_of(AllowedOutboundBytesAtDest, AllowedInboundBytesAtSrc + BlockedInboundBytesAtSrc)\r\n | extend OutboundBytesAtSrc = AllowedOutboundBytesAtSrc_inferred + BlockedOutboundBytesAtSrc, InboundBytesAtSrc = AllowedOutboundBytesAtDest_inferred\r\n | extend OutboundBytesAtDest = AllowedOutboundBytesAtDest_inferred + BlockedOutboundBytesAtDest, InboundBytesAtDest = AllowedOutboundBytesAtSrc_inferred\r\n | extend BytesCount = max_of(OutboundBytesAtSrc, InboundBytesAtDest) + max_of(OutboundBytesAtDest, InboundBytesAtSrc)\r\n | extend AllowedInboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), AllowedInboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0)\r\n | extend AllowedOutboundPacketsAtSrc_inferred = max_of(AllowedOutboundPacketsAtSrc, AllowedInboundPacketsAtDest + BlockedInboundPacketsAtDest)\r\n | extend AllowedOutboundPacketsAtDest_inferred = max_of(AllowedOutboundPacketsAtDest, AllowedInboundPacketsAtSrc + BlockedInboundPacketsAtSrc)\r\n | extend OutboundPacketsAtSrc = AllowedOutboundPacketsAtSrc_inferred + BlockedOutboundPacketsAtSrc, InboundPacketsAtSrc = AllowedOutboundPacketsAtDest_inferred\r\n | extend OutboundPacketsAtDest = AllowedOutboundPacketsAtDest_inferred + BlockedOutboundPacketsAtDest, InboundPacketsAtDest = AllowedOutboundPacketsAtSrc_inferred\r\n | extend PacketsCount = max_of(OutboundPacketsAtSrc, InboundPacketsAtDest) + max_of(OutboundPacketsAtDest, InboundPacketsAtSrc)\r\n | extend Gateway = substring(ConnectionName_s, 0, indexof_regex(ConnectionName_s, '_[^_]+$'))\r\n | where Gateway in~ ({top5Gateways});\r\nlineChartVPNGwS2SAndInterVNet\r\n| union lineChartVPNGwP2S\r\n| summarize TotalTraffic = sum(iff('{sortUnit:value}' =~ 'bytes', BytesCount, iff('{sortUnit:value}' =~ 'packets', PacketsCount, tolong(FlowCount))))\r\nby todatetime(ceiling(FlowStartTime_t / {binningTime}) * {binningTime})",
"size": 0,
"showAnalytics": true,
"showExportToExcel": true,
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
],
"visualization": "timechart"
},
"conditionalVisibility": {
"parameterName": "top5Gateways",
"comparison": "isNotEqualTo"
},
"showPin": true,
"name": "getLineChartDataPointsForGatewayStatistics"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "3df6c05c-9526-4072-842e-519cf239bf35",
"version": "KqlParameterItem/1.0",
"name": "displayUnit",
"label": "Display traffic in",
"type": 2,
"description": "The traffic will be shown in this unit.",
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"jsonData": "[\r\n { \"value\":\"flows\", \"label\":\"Flows\", \"selected\":true },\r\n { \"value\":\"bytes\", \"label\":\"Bytes\" },\r\n { \"value\":\"packets\", \"label\":\"Packets\"}\r\n]",
"timeContext": {
"durationMs": 86400000
}
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"name": "parameters - 3 - Copy"
},
{
"type": 1,
"content": {
"json": "##### VPN gateway statistics"
},
"name": "text - 14"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let ValueWithUnit = (x:real, precision:int) {\r\n iff(x < 1000, strcat(tostring(round(x, precision)), ''), \r\n iff(x < 1000000, strcat(tostring(round(x/1000, precision)), ' {thousandUnit}'), \r\n iff(x < 1000000000, strcat(tostring(round(x/1000000, precision)), ' {millionUnit}'), \r\n iff(x < 1000000000000, strcat(tostring(round(x/1000000000, precision)), ' {billionUnit}'), \r\n iff(x < 1000000000000000, strcat(tostring(round(x/1000000000000, precision)), ' {trillionUnit}'), \r\n strcat(tostring(round(x/1000000000000000, precision)), ' {quadrillionUnit}'))))))\r\n};\r\nlet trafficDistributionVPNGwS2SAndInterVNet =\r\n (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection' and ConnectionType_s in ('Vnet2Vnet', 'IPsec') and {timeIntervalTopologyCheck}\r\n | where VirtualNetworkGateway1_s in~ ({vpnGateways}) or VirtualNetworkGateway2_s in~ ({vpnGateways})\r\n | extend ConnectionName_s = strcat(Subscription_g, '/', Name_s)\r\n {vpnGatewayConnectionCheck}\r\n | distinct ConnectionName_s, VirtualNetworkGateway1_s, VirtualNetworkGateway2_s)\r\n | mv-expand Gateway = pack_array(VirtualNetworkGateway1_s, VirtualNetworkGateway2_s) to typeof(string)\r\n | where isnotempty(Gateway) and Gateway in~ ({vpnGateways})\r\n | join kind = inner\r\n (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s in ('S2S', 'InterVNet') and ConnectionType_s == 'VpnGateway')\r\n on ConnectionName_s\r\n | extend Direction = iif((FlowType_s == 'InterVNet' and VirtualNetworkGateway1_s in~ ({vpnGateways})) or (FlowType_s != 'InterVNet' and isnotempty(VM1_s)), 'Source', 'Destination');\r\nlet trafficDistributionVPNGwP2S =\r\n AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s == 'P2S' and ConnectionType_s == 'VpnGateway'\r\n | extend Gateway = substring(ConnectionName_s, 0, indexof_regex(ConnectionName_s, '_[^_]+$'))\r\n | where Gateway in~ ({vpnGateways})\r\n | extend Direction = iif(isnotempty(VM1_s), 'Source', 'Destination');\r\nlet common = trafficDistributionVPNGwS2SAndInterVNet\r\n | union trafficDistributionVPNGwP2S\r\n | extend CountryOrRegion = iif(FlowType_s == 'AzurePublic', AzureRegion_s, Country_s)\r\n | extend AllowedInboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), BlockedInboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), AllowedInboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), BlockedInboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0)\r\n | extend AllowedInboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), AllowedInboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0)\r\n | extend FlowDirection_s = iif(FlowType_s in ('InterVNet', 'IntraVNet'), '', FlowDirection_s)\r\n | summarize \r\n AllowedInbound = sum(AllowedInFlows_d), BlockedInbound = sum(DeniedInFlows_d), AllowedOutbound = sum(AllowedOutFlows_d), BlockedOutbound = sum(DeniedOutFlows_d),\r\n AllowedInboundBytesAtSrc = sum(AllowedInboundBytesAtSrc), BlockedInboundBytesAtSrc = sum(BlockedInboundBytesAtSrc), AllowedOutboundBytesAtSrc = sum(AllowedOutboundBytesAtSrc), BlockedOutboundBytesAtSrc = sum(BlockedOutboundBytesAtSrc), AllowedInboundBytesAtDest = sum(AllowedInboundBytesAtDest), BlockedInboundBytesAtDest = sum(BlockedInboundBytesAtDest), AllowedOutboundBytesAtDest = sum(AllowedOutboundBytesAtDest), BlockedOutboundBytesAtDest = sum(BlockedOutboundBytesAtDest),\r\n AllowedInboundPacketsAtSrc = sum(AllowedInboundPacketsAtSrc), BlockedInboundPacketsAtSrc = sum(BlockedInboundPacketsAtSrc), AllowedOutboundPacketsAtSrc = sum(AllowedOutboundPacketsAtSrc), BlockedOutboundPacketsAtSrc = sum(BlockedOutboundPacketsAtSrc), AllowedInboundPacketsAtDest = sum(AllowedInboundPacketsAtDest), BlockedInboundPacketsAtDest = sum(BlockedInboundPacketsAtDest), AllowedOutboundPacketsAtDest = sum(AllowedOutboundPacketsAtDest), BlockedOutboundPacketsAtDest = sum(BlockedOutboundPacketsAtDest)\r\n by SrcIP_s, Subscription1_g, NIC1_s, DestIP_s, Subscription2_g, NIC2_s, FlowDirection_s, L4Protocol_s, DestPort_d, CountryOrRegion, Direction, Gateway\r\n | extend AllowedOutbound_inferred = max_of(AllowedOutbound, AllowedInbound + BlockedInbound)\r\n | extend Outbound = AllowedOutbound_inferred + BlockedOutbound, Inbound = AllowedOutbound_inferred\r\n | extend FlowCount = max_of(Inbound, Outbound)\r\n | extend AllowedInbound = iif(Direction == 'Destination', tolong(AllowedInbound), 0), BlockedInbound = iif(Direction == 'Destination', tolong(BlockedInbound), 0), AllowedOutbound = iif(Direction == 'Source', tolong(AllowedOutbound_inferred), 0), BlockedOutbound = iif(Direction == 'Source', tolong(BlockedOutbound), 0)\r\n | extend AllowedOutboundBytesAtSrc_inferred = max_of(AllowedOutboundBytesAtSrc, AllowedInboundBytesAtDest + BlockedInboundBytesAtDest)\r\n | extend AllowedOutboundBytesAtDest_inferred = max_of(AllowedOutboundBytesAtDest, AllowedInboundBytesAtSrc + BlockedInboundBytesAtSrc)\r\n | extend OutboundBytesAtSrc = AllowedOutboundBytesAtSrc_inferred + BlockedOutboundBytesAtSrc, InboundBytesAtSrc = AllowedOutboundBytesAtDest_inferred\r\n | extend OutboundBytesAtDest = AllowedOutboundBytesAtDest_inferred + BlockedOutboundBytesAtDest, InboundBytesAtDest = AllowedOutboundBytesAtSrc_inferred\r\n | extend BytesCount = max_of(OutboundBytesAtSrc, InboundBytesAtDest) + max_of(OutboundBytesAtDest, InboundBytesAtSrc)\r\n | extend AllowedInboundBytes = iif(Direction == 'Source', tolong(AllowedInboundBytesAtSrc), tolong(AllowedInboundBytesAtDest)), BlockedInboundBytes = iif(Direction == 'Source', tolong(BlockedInboundBytesAtSrc), tolong(BlockedInboundBytesAtDest)), AllowedOutboundBytes = iif(Direction == 'Source', tolong(AllowedOutboundBytesAtSrc_inferred), tolong(AllowedOutboundBytesAtDest_inferred)), BlockedOutboundBytes = iif(Direction == 'Source', tolong(BlockedOutboundBytesAtSrc), tolong(BlockedOutboundBytesAtDest))\r\n | extend AllowedOutboundPacketsAtSrc_inferred = max_of(AllowedOutboundPacketsAtSrc, AllowedInboundPacketsAtDest + BlockedInboundPacketsAtDest)\r\n | extend AllowedOutboundPacketsAtDest_inferred = max_of(AllowedOutboundPacketsAtDest, AllowedInboundPacketsAtSrc + BlockedInboundPacketsAtSrc)\r\n | extend OutboundPacketsAtSrc = AllowedOutboundPacketsAtSrc_inferred + BlockedOutboundPacketsAtSrc, InboundPacketsAtSrc = AllowedOutboundPacketsAtDest_inferred\r\n | extend OutboundPacketsAtDest = AllowedOutboundPacketsAtDest_inferred + BlockedOutboundPacketsAtDest, InboundPacketsAtDest = AllowedOutboundPacketsAtSrc_inferred\r\n | extend PacketsCount = max_of(OutboundPacketsAtSrc, InboundPacketsAtDest) + max_of(OutboundPacketsAtDest, InboundPacketsAtSrc)\r\n | extend AllowedInboundPackets = iif(Direction == 'Source', tolong(AllowedInboundPacketsAtSrc), tolong(AllowedInboundPacketsAtDest)), BlockedInboundPackets = iif(Direction == 'Source', tolong(BlockedInboundPacketsAtSrc), tolong(BlockedInboundPacketsAtDest)), AllowedOutboundPackets = iif(Direction == 'Source', tolong(AllowedOutboundPacketsAtSrc_inferred), tolong(AllowedOutboundPacketsAtDest_inferred)), BlockedOutboundPackets = iif(Direction == 'Source', tolong(BlockedOutboundPacketsAtSrc), tolong(BlockedOutboundPacketsAtDest))\r\n | extend trafficForSorting = iff('{sortUnit:value}' =~ 'bytes', BytesCount, iff('{sortUnit:value}' =~ 'packets', PacketsCount, tolong(FlowCount)))\r\n | summarize totalAllowedInbound = sum(AllowedInbound), totalBlockedInbound = sum(BlockedInbound), totalAllowedOutbound = sum(AllowedOutbound), totalBlockedOutbound = sum(BlockedOutbound), totalAllowedInboundBytes = sum(AllowedInboundBytes), totalBlockedInboundBytes = sum(BlockedInboundBytes), totalAllowedOutboundBytes = sum(AllowedOutboundBytes), totalBlockedOutboundBytes = sum(BlockedOutboundBytes), totalAllowedInboundPackets = sum(AllowedInboundPackets), totalBlockedInboundPackets = sum(BlockedInboundPackets), totalAllowedOutboundPackets = sum(AllowedOutboundPackets), totalBlockedOutboundPackets = sum(BlockedOutboundPackets) by Gateway, trafficForSorting \r\n | where trafficForSorting > 0\r\n | project Gateway, trafficForSorting,\r\n InboundAllowed = iff('{displayUnit:value}' =~ 'bytes', format_bytes(totalAllowedInboundBytes, 3), iff('{displayUnit:value}' =~ 'packets', ValueWithUnit(totalAllowedInboundPackets, 3), ValueWithUnit(totalAllowedInbound, 3))),\r\n InboundBlocked = iff('{displayUnit:value}' =~ 'bytes', format_bytes(totalBlockedInboundBytes, 3), iff('{displayUnit:value}' =~ 'packets', ValueWithUnit(totalBlockedInboundPackets, 3), ValueWithUnit(totalBlockedInbound, 3))),\r\n OutboundAllowed = iff('{displayUnit:value}' =~ 'bytes', format_bytes(totalAllowedOutboundBytes, 3), iff('{displayUnit:value}' =~ 'packets', ValueWithUnit(totalAllowedOutboundPackets, 3), ValueWithUnit(totalAllowedOutbound, 3))),\r\n OutboundBlocked = iff('{displayUnit:value}' =~ 'bytes', format_bytes(totalBlockedOutboundBytes, 3), iff('{displayUnit:value}' =~ 'packets', ValueWithUnit(totalBlockedOutboundPackets, 3), ValueWithUnit(totalBlockedOutbound, 3)));\r\n//\r\nlet topHostsVPNGwS2SAndInterVNet = (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection' and ConnectionType_s in ('Vnet2Vnet', 'IPsec') and {timeIntervalTopologyCheck}\r\n | where VirtualNetworkGateway1_s in~ ({vpnGateways}) or VirtualNetworkGateway2_s in~ ({vpnGateways})\r\n | extend ConnectionName_s = strcat(Subscription_g, '/', Name_s)\r\n {vpnGatewayConnectionCheck}\r\n | distinct ConnectionName_s, VirtualNetworkGateway1_s, VirtualNetworkGateway2_s)\r\n | mv-expand Gateway = pack_array(VirtualNetworkGateway1_s, VirtualNetworkGateway2_s) to typeof(string)\r\n | where isnotempty(Gateway) and Gateway in~ ({vpnGateways})\r\n | join kind = inner (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s in ('S2S', 'InterVNet') and ConnectionType_s == 'VpnGateway')\r\n on ConnectionName_s\r\n | extend host1 = strcat(Subscription1_g, '/', VM1_s), host2 = strcat(Subscription2_g, '/', VM2_s)\r\n | extend Direction = iif((FlowType_s == 'InterVNet' and VirtualNetworkGateway1_s in~ ({vpnGateways})) or (FlowType_s != 'InterVNet' and isnotempty(VM1_s)), 'Source', 'Destination')\r\n | extend host = iif(Direction == 'Source', host1, host2);\r\nlet topHostsVPNGwP2S = AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s == 'P2S' and ConnectionType_s == 'VpnGateway'\r\n | extend Gateway = substring(ConnectionName_s, 0, indexof_regex(ConnectionName_s, '_[^_]+$'))\r\n | where Gateway in~ ({vpnGateways})\r\n | extend host1 = strcat(Subscription1_g, '/', VM1_s), host2 = strcat(Subscription2_g, '/', VM2_s)\r\n | extend Direction = iif(isnotempty(VM1_s), 'Source', 'Destination')\r\n | extend host = iif(Direction == 'Source', host1, host2);\r\nlet table1 = topHostsVPNGwS2SAndInterVNet\r\n | union topHostsVPNGwP2S\r\n | extend CountryOrRegion = iif(FlowType_s == 'AzurePublic', AzureRegion_s, Country_s)\r\n | extend AllowedInboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), BlockedInboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), AllowedInboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), BlockedInboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0)\r\n | extend AllowedInboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), AllowedInboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0)\r\n | extend FlowDirection_s = iif(FlowType_s in ('InterVNet', 'IntraVNet'), '', FlowDirection_s)\r\n | summarize \r\n AllowedInbound = sum(AllowedInFlows_d), BlockedInbound = sum(DeniedInFlows_d), AllowedOutbound = sum(AllowedOutFlows_d), BlockedOutbound = sum(DeniedOutFlows_d),\r\n AllowedInboundBytesAtSrc = sum(AllowedInboundBytesAtSrc), BlockedInboundBytesAtSrc = sum(BlockedInboundBytesAtSrc), AllowedOutboundBytesAtSrc = sum(AllowedOutboundBytesAtSrc), BlockedOutboundBytesAtSrc = sum(BlockedOutboundBytesAtSrc), AllowedInboundBytesAtDest = sum(AllowedInboundBytesAtDest), BlockedInboundBytesAtDest = sum(BlockedInboundBytesAtDest), AllowedOutboundBytesAtDest = sum(AllowedOutboundBytesAtDest), BlockedOutboundBytesAtDest = sum(BlockedOutboundBytesAtDest),\r\n AllowedInboundPacketsAtSrc = sum(AllowedInboundPacketsAtSrc), BlockedInboundPacketsAtSrc = sum(BlockedInboundPacketsAtSrc), AllowedOutboundPacketsAtSrc = sum(AllowedOutboundPacketsAtSrc), BlockedOutboundPacketsAtSrc = sum(BlockedOutboundPacketsAtSrc), AllowedInboundPacketsAtDest = sum(AllowedInboundPacketsAtDest), BlockedInboundPacketsAtDest = sum(BlockedInboundPacketsAtDest), AllowedOutboundPacketsAtDest = sum(AllowedOutboundPacketsAtDest), BlockedOutboundPacketsAtDest = sum(BlockedOutboundPacketsAtDest)\r\n by SrcIP_s, Subscription1_g, NIC1_s, DestIP_s, Subscription2_g, NIC2_s, FlowDirection_s, L4Protocol_s, DestPort_d, CountryOrRegion, host, Direction, Gateway\r\n | extend AllowedOutbound_inferred = max_of(AllowedOutbound, AllowedInbound + BlockedInbound)\r\n | extend Outbound = AllowedOutbound_inferred + BlockedOutbound, Inbound = AllowedOutbound_inferred\r\n | extend FlowCount = max_of(Inbound, Outbound)\r\n | extend AllowedOutboundBytesAtSrc_inferred = max_of(AllowedOutboundBytesAtSrc, AllowedInboundBytesAtDest + BlockedInboundBytesAtDest)\r\n | extend AllowedOutboundBytesAtDest_inferred = max_of(AllowedOutboundBytesAtDest, AllowedInboundBytesAtSrc + BlockedInboundBytesAtSrc)\r\n | extend OutboundBytesAtSrc = AllowedOutboundBytesAtSrc_inferred + BlockedOutboundBytesAtSrc, InboundBytesAtSrc = AllowedOutboundBytesAtDest_inferred\r\n | extend OutboundBytesAtDest = AllowedOutboundBytesAtDest_inferred + BlockedOutboundBytesAtDest, InboundBytesAtDest = AllowedOutboundBytesAtSrc_inferred\r\n | extend BytesCount = max_of(OutboundBytesAtSrc, InboundBytesAtDest) + max_of(OutboundBytesAtDest, InboundBytesAtSrc)\r\n | extend AllowedOutboundPacketsAtSrc_inferred = max_of(AllowedOutboundPacketsAtSrc, AllowedInboundPacketsAtDest + BlockedInboundPacketsAtDest)\r\n | extend AllowedOutboundPacketsAtDest_inferred = max_of(AllowedOutboundPacketsAtDest, AllowedInboundPacketsAtSrc + BlockedInboundPacketsAtSrc)\r\n | extend OutboundPacketsAtSrc = AllowedOutboundPacketsAtSrc_inferred + BlockedOutboundPacketsAtSrc, InboundPacketsAtSrc = AllowedOutboundPacketsAtDest_inferred\r\n | extend OutboundPacketsAtDest = AllowedOutboundPacketsAtDest_inferred + BlockedOutboundPacketsAtDest, InboundPacketsAtDest = AllowedOutboundPacketsAtSrc_inferred\r\n | extend PacketsCount = max_of(OutboundPacketsAtSrc, InboundPacketsAtDest) + max_of(OutboundPacketsAtDest, InboundPacketsAtSrc)\r\n | extend ip = iif(Direction == 'Source', SrcIP_s, DestIP_s)\r\n | summarize TotalTraffic = sum(iff('{sortUnit:value}' =~ 'bytes', BytesCount, iff('{sortUnit:value}' =~ 'packets', PacketsCount, tolong(FlowCount)))) by ip, host, Gateway\r\n | top-nested of Gateway by max(1), top-nested 3 of partnerInfo = strcat(ip, '#', host) by max(TotalTraffic)\r\n | project Gateway, partnerInfo\r\n | summarize topHostsData = strcat_array(make_list(strcat(split(partnerInfo, '#')[0],' (',split(partnerInfo, '#')[1],')')), ',') by Gateway\r\n | project Gateway, topHostsData;\r\n//\r\nlet topGwConnectionsS2SAndInterVNet = (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection' and ConnectionType_s in ('Vnet2Vnet', 'IPsec') and {timeIntervalTopologyCheck}\r\n | where VirtualNetworkGateway1_s in~ ({vpnGateways}) or VirtualNetworkGateway2_s in~ ({vpnGateways})\r\n | mv-expand Gateway = pack_array(VirtualNetworkGateway1_s, VirtualNetworkGateway2_s) to typeof(string)\r\n | where isnotempty(Gateway) and Gateway in~ ({vpnGateways})\r\n | extend ConnectionName_s = strcat(Subscription_g, '/', Name_s)\r\n {vpnGatewayConnectionCheck}\r\n | distinct ConnectionName_s)\r\n | join kind = inner (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s in ('S2S', 'InterVNet') and ConnectionType_s == 'VpnGateway')\r\n on ConnectionName_s;\r\nlet topGwConnectionsP2S = AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s == 'P2S' and ConnectionType_s == 'VpnGateway'\r\n | extend Gateway = substring(ConnectionName_s, 0, indexof_regex(ConnectionName_s, '_[^_]+$'))\r\n | where Gateway in~ ({vpnGateways});\r\nlet table2 = topGwConnectionsS2SAndInterVNet\r\n | union topGwConnectionsP2S\r\n | extend CountryOrRegion = iif(FlowType_s == 'AzurePublic', AzureRegion_s, Country_s)\r\n | extend AllowedInboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), BlockedInboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), AllowedInboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), BlockedInboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0)\r\n | extend AllowedInboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), AllowedInboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0)\r\n | extend FlowDirection_s = iif(FlowType_s in ('InterVNet', 'IntraVNet'), '', FlowDirection_s)\r\n | summarize \r\n AllowedInbound = sum(AllowedInFlows_d), BlockedInbound = sum(DeniedInFlows_d), AllowedOutbound = sum(AllowedOutFlows_d), BlockedOutbound = sum(DeniedOutFlows_d),\r\n AllowedInboundBytesAtSrc = sum(AllowedInboundBytesAtSrc), BlockedInboundBytesAtSrc = sum(BlockedInboundBytesAtSrc), AllowedOutboundBytesAtSrc = sum(AllowedOutboundBytesAtSrc), BlockedOutboundBytesAtSrc = sum(BlockedOutboundBytesAtSrc), AllowedInboundBytesAtDest = sum(AllowedInboundBytesAtDest), BlockedInboundBytesAtDest = sum(BlockedInboundBytesAtDest), AllowedOutboundBytesAtDest = sum(AllowedOutboundBytesAtDest), BlockedOutboundBytesAtDest = sum(BlockedOutboundBytesAtDest),\r\n AllowedInboundPacketsAtSrc = sum(AllowedInboundPacketsAtSrc), BlockedInboundPacketsAtSrc = sum(BlockedInboundPacketsAtSrc), AllowedOutboundPacketsAtSrc = sum(AllowedOutboundPacketsAtSrc), BlockedOutboundPacketsAtSrc = sum(BlockedOutboundPacketsAtSrc), AllowedInboundPacketsAtDest = sum(AllowedInboundPacketsAtDest), BlockedInboundPacketsAtDest = sum(BlockedInboundPacketsAtDest), AllowedOutboundPacketsAtDest = sum(AllowedOutboundPacketsAtDest), BlockedOutboundPacketsAtDest = sum(BlockedOutboundPacketsAtDest)\r\n by SrcIP_s, Subscription1_g, NIC1_s, DestIP_s, Subscription2_g, NIC2_s, FlowDirection_s, L4Protocol_s, DestPort_d, CountryOrRegion, ConnectionName_s, Gateway\r\n | extend AllowedOutbound_inferred = max_of(AllowedOutbound, AllowedInbound + BlockedInbound)\r\n | extend Outbound = AllowedOutbound_inferred + BlockedOutbound, Inbound = AllowedOutbound_inferred\r\n | extend FlowCount = max_of(Inbound, Outbound)\r\n | extend AllowedOutboundBytesAtSrc_inferred = max_of(AllowedOutboundBytesAtSrc, AllowedInboundBytesAtDest + BlockedInboundBytesAtDest)\r\n | extend AllowedOutboundBytesAtDest_inferred = max_of(AllowedOutboundBytesAtDest, AllowedInboundBytesAtSrc + BlockedInboundBytesAtSrc)\r\n | extend OutboundBytesAtSrc = AllowedOutboundBytesAtSrc_inferred + BlockedOutboundBytesAtSrc, InboundBytesAtSrc = AllowedOutboundBytesAtDest_inferred\r\n | extend OutboundBytesAtDest = AllowedOutboundBytesAtDest_inferred + BlockedOutboundBytesAtDest, InboundBytesAtDest = AllowedOutboundBytesAtSrc_inferred\r\n | extend BytesCount = max_of(OutboundBytesAtSrc, InboundBytesAtDest) + max_of(OutboundBytesAtDest, InboundBytesAtSrc)\r\n | extend AllowedOutboundPacketsAtSrc_inferred = max_of(AllowedOutboundPacketsAtSrc, AllowedInboundPacketsAtDest + BlockedInboundPacketsAtDest)\r\n | extend AllowedOutboundPacketsAtDest_inferred = max_of(AllowedOutboundPacketsAtDest, AllowedInboundPacketsAtSrc + BlockedInboundPacketsAtSrc)\r\n | extend OutboundPacketsAtSrc = AllowedOutboundPacketsAtSrc_inferred + BlockedOutboundPacketsAtSrc, InboundPacketsAtSrc = AllowedOutboundPacketsAtDest_inferred\r\n | extend OutboundPacketsAtDest = AllowedOutboundPacketsAtDest_inferred + BlockedOutboundPacketsAtDest, InboundPacketsAtDest = AllowedOutboundPacketsAtSrc_inferred\r\n | extend PacketsCount = max_of(OutboundPacketsAtSrc, InboundPacketsAtDest) + max_of(OutboundPacketsAtDest, InboundPacketsAtSrc)\r\n | summarize TotalTraffic = sum(iff('{sortUnit:value}' =~ 'bytes', BytesCount, iff('{sortUnit:value}' =~ 'packets', PacketsCount, tolong(FlowCount)))) by ConnectionName_s, Gateway\r\n | top-nested of Gateway by max(1), top-nested 3 of ConnectionName_s by max(TotalTraffic)\r\n | project Gateway, ConnectionName_s\r\n | summarize topConnections = strcat_array(make_list(ConnectionName_s), ',') by Gateway\r\n | project Gateway, topConnections;\r\n//\r\nlet topDestPortVpnGwS2SAndInterVNet = (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'Topology' and ResourceType == 'VirtualNetworkGatewayConnection' and ConnectionType_s in ('Vnet2Vnet', 'IPsec') and {timeIntervalTopologyCheck}\r\n | where VirtualNetworkGateway1_s in~ ({vpnGateways}) or VirtualNetworkGateway2_s in~ ({vpnGateways})\r\n | extend ConnectionName_s = strcat(Subscription_g, '/', Name_s)\r\n {vpnGatewayConnectionCheck}\r\n | distinct ConnectionName_s, VirtualNetworkGateway1_s, VirtualNetworkGateway2_s)\r\n | join kind = inner (AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | where FlowType_s in ('S2S', 'InterVNet') and ConnectionType_s == 'VpnGateway')\r\n on ConnectionName_s\r\n | where (FlowType_s == 'InterVNet' and VirtualNetworkGateway2_s in~ ({vpnGateways})) or (FlowType_s != 'InterVNet' and isnotempty(VM2_s))\r\n | extend Gateway = VirtualNetworkGateway2_s;\r\nlet topDestPortVpnGwP2S = AzureNetworkAnalytics_CL\r\n | where SubType_s == 'FlowLog' and (FASchemaVersion_s == '1' or FASchemaVersion_s == '2') and {timeIntervalFlowlogCheck} and FlowStartTime_t between (datetime('{timeInterval:startISO}') .. datetime('{timeInterval:endISO}'))\r\n | extend Gateway = substring(ConnectionName_s, 0, indexof_regex(ConnectionName_s, '_[^_]+$'))\r\n | where Gateway in~ ({vpnGateways}) and isnotempty(VM2_s);\r\nlet table3 = topDestPortVpnGwS2SAndInterVNet\r\n | union topDestPortVpnGwP2S\r\n | extend CountryOrRegion = iif(FlowType_s == 'AzurePublic', AzureRegion_s, Country_s)\r\n | extend AllowedInboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), BlockedInboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundBytes_d), 0), AllowedInboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), BlockedInboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundBytes_d), 0), AllowedOutboundBytesAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0), BlockedOutboundBytesAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundBytes_d), 0)\r\n | extend AllowedInboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtSrc = iff(FlowStatus_s == 'A' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtSrc = iff(FlowStatus_s == 'D' and FlowDirection_s == 'O', tolong(OutboundPackets_d), 0), AllowedInboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), BlockedInboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(InboundPackets_d), 0), AllowedOutboundPacketsAtDest = iff(FlowStatus_s == 'A' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0), BlockedOutboundPacketsAtDest = iff(FlowStatus_s == 'D' and FlowDirection_s == 'I', tolong(OutboundPackets_d), 0)\r\n | extend FlowDirection_s = iif(FlowType_s in ('InterVNet', 'IntraVNet'), '', FlowDirection_s)\r\n | summarize \r\n AllowedInbound = sum(AllowedInFlows_d), BlockedInbound = sum(DeniedInFlows_d), AllowedOutbound = sum(AllowedOutFlows_d), BlockedOutbound = sum(DeniedOutFlows_d),\r\n AllowedInboundBytesAtSrc = sum(AllowedInboundBytesAtSrc), BlockedInboundBytesAtSrc = sum(BlockedInboundBytesAtSrc), AllowedOutboundBytesAtSrc = sum(AllowedOutboundBytesAtSrc), BlockedOutboundBytesAtSrc = sum(BlockedOutboundBytesAtSrc), AllowedInboundBytesAtDest = sum(AllowedInboundBytesAtDest), BlockedInboundBytesAtDest = sum(BlockedInboundBytesAtDest), AllowedOutboundBytesAtDest = sum(AllowedOutboundBytesAtDest), BlockedOutboundBytesAtDest = sum(BlockedOutboundBytesAtDest),\r\n AllowedInboundPacketsAtSrc = sum(AllowedInboundPacketsAtSrc), BlockedInboundPacketsAtSrc = sum(BlockedInboundPacketsAtSrc), AllowedOutboundPacketsAtSrc = sum(AllowedOutboundPacketsAtSrc), BlockedOutboundPacketsAtSrc = sum(BlockedOutboundPacketsAtSrc), AllowedInboundPacketsAtDest = sum(AllowedInboundPacketsAtDest), BlockedInboundPacketsAtDest = sum(BlockedInboundPacketsAtDest), AllowedOutboundPacketsAtDest = sum(AllowedOutboundPacketsAtDest), BlockedOutboundPacketsAtDest = sum(BlockedOutboundPacketsAtDest)\r\n by SrcIP_s, Subscription1_g, NIC1_s, DestIP_s, Subscription2_g, NIC2_s, FlowDirection_s, L4Protocol_s, DestPort_d, CountryOrRegion, Gateway\r\n | extend AllowedOutbound_inferred = max_of(AllowedOutbound, AllowedInbound + BlockedInbound)\r\n | extend Outbound = AllowedOutbound_inferred + BlockedOutbound, Inbound = AllowedOutbound_inferred\r\n | extend FlowCount = max_of(Inbound, Outbound)\r\n | extend AllowedOutboundBytesAtSrc_inferred = max_of(AllowedOutboundBytesAtSrc, AllowedInboundBytesAtDest + BlockedInboundBytesAtDest)\r\n | extend AllowedOutboundBytesAtDest_inferred = max_of(AllowedOutboundBytesAtDest, AllowedInboundBytesAtSrc + BlockedInboundBytesAtSrc)\r\n | extend OutboundBytesAtSrc = AllowedOutboundBytesAtSrc_inferred + BlockedOutboundBytesAtSrc, InboundBytesAtSrc = AllowedOutboundBytesAtDest_inferred\r\n | extend OutboundBytesAtDest = AllowedOutboundBytesAtDest_inferred + BlockedOutboundBytesAtDest, InboundBytesAtDest = AllowedOutboundBytesAtSrc_inferred\r\n | extend BytesCount = max_of(OutboundBytesAtSrc, InboundBytesAtDest) + max_of(OutboundBytesAtDest, InboundBytesAtSrc)\r\n | extend AllowedOutboundPacketsAtSrc_inferred = max_of(AllowedOutboundPacketsAtSrc, AllowedInboundPacketsAtDest + BlockedInboundPacketsAtDest)\r\n | extend AllowedOutboundPacketsAtDest_inferred = max_of(AllowedOutboundPacketsAtDest, AllowedInboundPacketsAtSrc + BlockedInboundPacketsAtSrc)\r\n | extend OutboundPacketsAtSrc = AllowedOutboundPacketsAtSrc_inferred + BlockedOutboundPacketsAtSrc, InboundPacketsAtSrc = AllowedOutboundPacketsAtDest_inferred\r\n | extend OutboundPacketsAtDest = AllowedOutboundPacketsAtDest_inferred + BlockedOutboundPacketsAtDest, InboundPacketsAtDest = AllowedOutboundPacketsAtSrc_inferred\r\n | extend PacketsCount = max_of(OutboundPacketsAtSrc, InboundPacketsAtDest) + max_of(OutboundPacketsAtDest, InboundPacketsAtSrc)\r\n | summarize TotalTraffic = sum(iff('{sortUnit:value}' =~ 'bytes', BytesCount, iff('{sortUnit:value}' =~ 'packets', PacketsCount, tolong(FlowCount)))) by DestPort_d, Gateway\r\n | top-nested of Gateway by max(1), top-nested 3 of DestPort_d by max(TotalTraffic)\r\n | project Gateway, DestPort_d\r\n | summarize topDestPort = strcat_array(make_list(DestPort_d), ',') by Gateway\r\n | project Gateway, topDestPort;\r\ncommon\r\n| join kind=leftouter table1 on $left.Gateway == $right.Gateway\r\n| join kind=leftouter table2 on $left.Gateway == $right.Gateway\r\n| join kind=leftouter table3 on $left.Gateway == $right.Gateway\r\n| sort by trafficForSorting desc\r\n| project Gateway, topConnections, topHostsData, topDestPort, InboundAllowed, InboundBlocked, OutboundAllowed, OutboundBlocked",
"size": 0,
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"crossComponentResources": [
"{workspace}"
]
},
"name": "query - 15"
}
],
"fallbackResourceIds": [
"Azure Monitor"
],
"$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}