Repository navigation
Expand file tree
/
Copy pathactivity.workbook
More file actions
1352 lines (1352 loc) · 67.6 KB
/
Copy pathactivity.workbook
File metadata and controls
1352 lines (1352 loc) · 67.6 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
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
{
"version": "Notebook/1.0",
"items": [
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "eb139db6-a5e2-4c94-aead-297fab717765",
"version": "KqlParameterItem/1.0",
"name": "activitySampleType",
"label": "Data to show",
"type": 10,
"description": "\"Last available\" shows the most recent sample within specified time range, if any. \"Historical\" lets you select any sample within specified time range. Refresh the workbook to see most recent samples.",
"isRequired": true,
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"jsonData": "[{\"value\":\"Latest\",\"label\":\"Last available\"},{\"value\":\"Historical\",\"label\":\"Historical\"}]",
"timeContext": {
"durationMs": 86400000
},
"value": "Latest"
}
],
"style": "formHorizontal",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"customWidth": "50",
"name": "activity_sample_type_parameters"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "dfaf53a4-40fc-486d-a130-437ff6b91eb2",
"version": "KqlParameterItem/1.0",
"name": "activitySampleSubType",
"label": "Samples to show",
"type": 10,
"description": "\"All\" shows all activity samples. \"Blocked\" shows only samples where blocked sessions are present.",
"isRequired": true,
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"jsonData": "[{\"value\":\"all\",\"label\":\"All\"},{\"value\":\"blocked\",\"label\":\"Blocked\"}]",
"timeContext": {
"durationMs": 86400000
},
"value": "all"
}
],
"style": "formHorizontal",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"conditionalVisibility": {
"parameterName": "activitySampleType",
"comparison": "isEqualTo",
"value": "Historical"
},
"customWidth": "50",
"name": "activity_sample_subtype_parameters"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"sqldb_database_active_sessions\\r\\n| where sample_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| extend blocking_session_id = iif(\\r\\n blocking_session_id in (0, -4, -5), // Do not treat long latch waits as relevant blocking\\r\\n int(null),\\r\\n blocking_session_id\\r\\n )\\r\\n| extend sample_subtype = iif(isnotempty(blocking_session_id), \\\"blocked\\\", \\\"not_blocked\\\")\\r\\n| where \\\"{activitySampleSubType}\\\" == \\\"all\\\" or (\\\"{activitySampleSubType}\\\" == \\\"blocked\\\" and sample_subtype == \\\"{activitySampleSubType}\\\")\\r\\n| make-series metric = dcount(sample_time_utc) default = long(null) on sample_time_utc from {timeRange:start} to {timeRange:end} step {timeRange:grain}/{grainFactor}*2 by sample_subtype\\r\\n\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"size": 4,
"aggregation": 3,
"title": "Select a sample",
"noDataMessage": "No activity samples are available",
"timeBrushParameterName": "timeRange",
"exportFieldName": "",
"exportParameterName": "activityHistoricalSample",
"exportDefaultValue": "0",
"queryType": 9,
"visualization": "barchart",
"chartSettings": {
"showMetrics": false,
"showLegend": true,
"seriesLabelSettings": [
{
"seriesName": "not_blocked",
"label": "Not blocked",
"color": "grayBlue"
},
{
"seriesName": "blocked",
"label": "Blocked",
"color": "orange"
}
]
}
},
"conditionalVisibility": {
"parameterName": "activitySampleType",
"comparison": "isEqualTo",
"value": "Historical"
},
"name": "activity_timeline"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"sqldb_database_active_sessions\\r\\n| where sample_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| summarize count_samples = dcount(sample_time_utc)\\r\\n| project strcat(\\\"There are `\\\", count_samples, \\\"` samples in the selected time range. Each vertical bar stands for a group of samples. Bar height is the number of samples in a group. Select a bar to view one sample from that group. Zoom in to see smaller sample groups, down to individual samples. Samples are not collected when there are no active sessions.\\\")\\r\\n\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"size": 3,
"noDataMessage": "No activity samples are available",
"queryType": 9,
"visualization": "card",
"textSettings": {
"style": "markdown"
}
},
"conditionalVisibility": {
"parameterName": "activitySampleType",
"comparison": "isEqualTo",
"value": "Historical"
},
"name": "activity_sample_count"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "8ef6f4e0-6f4b-4f96-bb11-1ea8fc44f3c1",
"version": "KqlParameterItem/1.0",
"name": "activityLatestSampleTime",
"type": 1,
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"sqldb_database_active_sessions\\r\\n| where sample_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| summarize sample_time_utc = max(sample_time_utc)\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"isHiddenWhenLocked": true,
"timeContext": {
"durationMs": 86400000
},
"queryType": 9
},
{
"id": "0a1027de-5009-4fd2-8769-366714c9a903",
"version": "KqlParameterItem/1.0",
"name": "activityHistoricalSampleTime",
"type": 1,
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"// Selected time from the history chart is a binned time generated by make-series and is unlikely to match an actual sample.\\r\\n// Look up an actual sample within the sample group selected on the history chart, differentiating between samples in different series.\\r\\nsqldb_database_active_sessions\\r\\n| where sample_time_utc between (todatetime(\\\"{activityHistoricalSample:$.x}\\\") .. (todatetime(\\\"{activityHistoricalSample:$.x}\\\") + {timeRange:grain}))\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| extend blocking_session_id = iif(blocking_session_id == 0, int(null), blocking_session_id)\\r\\n| extend sample_type = iif(isnotempty(blocking_session_id), \\\"blocked\\\", \\\"not_blocked\\\")\\r\\n| where sample_type == \\\"{activityHistoricalSample:$.series}\\\"\\r\\n| summarize sample_time_utc = min(sample_time_utc) // Selecting any sample within a sample group is valid. Use the earliest for determinism.\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"isHiddenWhenLocked": true,
"timeContext": {
"durationMs": 86400000
},
"queryType": 9
},
{
"id": "5734b987-5dff-4c5a-8b7f-019462c37c56",
"version": "KqlParameterItem/1.0",
"name": "activitySampleTime",
"type": 1,
"isHiddenWhenLocked": true,
"criteriaData": [
{
"criteriaContext": {
"leftOperand": "activitySampleType",
"operator": "==",
"rightValType": "static",
"rightVal": "Latest",
"resultValType": "param",
"resultVal": "activityLatestSampleTime"
}
},
{
"criteriaContext": {
"leftOperand": "activitySampleType",
"operator": "==",
"rightValType": "static",
"rightVal": "Historical",
"resultValType": "param",
"resultVal": "activityHistoricalSampleTime"
}
},
{
"criteriaContext": {
"operator": "Default",
"resultValType": "param",
"resultVal": "activityLatestSampleTime"
}
}
],
"timeContext": {
"durationMs": 86400000
}
}
],
"style": "formHorizontal",
"queryType": 9
},
"conditionalVisibility": {
"parameterName": "alwaysHidden",
"comparison": "isNotEqualTo"
},
"customWidth": "50",
"name": "activity_sample_time_parameters"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"sqldb_database_active_sessions\\r\\n| where sample_time_utc == todatetime(\\\"{activitySampleTime}\\\")\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| summarize count_sessions = count() by sample_time_utc\\r\\n| project sample_time = sample_time_utc, sample_time_utc, sample_age = format_timespan(now() - sample_time_utc, \\\"d.hh:mm:ss\\\"), count_sessions\\r\\n\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"size": 4,
"noDataMessage": "No sample is selected",
"queryType": 9,
"gridSettings": {
"formatters": [
{
"columnMatch": "sample_time",
"formatter": 6,
"formatOptions": {
"customColumnWidthSetting": "28ch"
},
"dateFormat": {
"showUtcTime": null,
"formatName": "shortDateTimeNoMsPattern"
}
},
{
"columnMatch": "sample_time_utc",
"formatter": 6,
"formatOptions": {
"customColumnWidthSetting": "28ch"
},
"dateFormat": {
"showUtcTime": true,
"formatName": "shortDateTimeNoMsPattern"
}
},
{
"columnMatch": "sample_age",
"formatter": 2,
"tooltipFormat": {
"tooltip": "Time difference between the last dashboard refresh and the displayed sample"
}
}
],
"labelSettings": [
{
"columnId": "sample_time",
"label": "Collection time"
},
{
"columnId": "sample_time_utc",
"label": "Collection time (UTC)"
},
{
"columnId": "sample_age",
"label": "Age of sample"
},
{
"columnId": "count_sessions",
"label": "Active sessions"
}
]
}
},
"conditionalVisibility": {
"parameterName": "activitySampleTime",
"comparison": "isNotEqualTo"
},
"customWidth": "50",
"name": "selected_activity_sample"
},
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"version": "KqlParameterItem/1.0",
"name": "blockedFilter",
"label": "Sessions to show",
"type": 10,
"description": "\"All\" shows all active sessions in a sample. \"Blocked\" shows all blocked sessions and the head blockers.",
"isRequired": true,
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"jsonData": "[\r\n {\"value\":\"all\",\"label\":\"All\"},\r\n {\"value\":\"blocked\",\"label\":\"Blocked\"}\r\n]",
"timeContext": {
"durationMs": 86400000
},
"value": "all",
"id": "4bcf0923-4f95-462c-aacb-36fc939bbac3"
}
],
"style": "formHorizontal",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"conditionalVisibility": {
"parameterName": "activitySampleTime",
"comparison": "isNotEqualTo"
},
"name": "blocked_filter_parameters"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"let max_missing_indexes_per_query_hash = 30;\\r\\n// The missing indexes table may not exist. Work around by using a same-schema stub in a fuzzy union.\\r\\nlet missing_indexes_stub = view() {\\r\\nprint query_hash = \\\"\\\", missing_index_label = \\\"\\\", create_index_statements = \\\"\\\"\\r\\n| where isnotempty(query_hash)\\r\\n};\\r\\nlet missing_indexes_table = view() {\\r\\nsqldb_database_missing_indexes\\r\\n| where sample_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n| where sample_time_utc <= todatetime(\\\"{activitySampleTime}\\\")\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| where grain_type == \\\"query_plan\\\"\\r\\n// Use the last missing index sample within the relevant interval\\r\\n| summarize arg_max(sample_time_utc, schema_name, object_name, database_engine_start_time_utc, avg_user_impact, equality_columns, inequality_columns, included_columns, user_seeks, user_scans, last_user_seek_utc, last_user_scan_utc)\\r\\n by logical_server_name, database_name, query_hash, query_plan_hash\\r\\n// Remove dups that may be present in different plans\\r\\n| summarize sample_time_utc = min(sample_time_utc),\\r\\n database_engine_start_time_utc = min(database_engine_start_time_utc),\\r\\n avg_user_impact = max(avg_user_impact),\\r\\n user_seeks = sum(user_seeks),\\r\\n user_scans = sum(user_scans),\\r\\n last_user_seek_utc = max(last_user_seek_utc),\\r\\n last_user_scan_utc = max(last_user_scan_utc),\\r\\n query_plan_hash = take_any(query_plan_hash),\\r\\n count_plans = dcount(query_plan_hash)\\r\\n by logical_server_name, database_name, query_hash, schema_name, object_name, equality_columns, inequality_columns, included_columns\\r\\n| extend duration_since_startup_seconds = 1s * datetime_diff(\\\"second\\\", sample_time_utc, database_engine_start_time_utc),\\r\\n query_plan_hash = iif(count_plans == 1, tostring(query_plan_hash), strcat(query_plan_hash, \\\" (+\\\", tostring(count_plans - 1), \\\")\\\"))\\r\\n| where not(schema_name has_any(\\\"[\\\",\\\"]\\\")) and not(object_name has_any(\\\"[\\\",\\\"]\\\"))\\r\\n| extend create_index_statement = strcat(\\r\\n\\\"/* \\\",\\r\\n\\\"\\\\r\\\\nLogical server: \\\", logical_server_name,\\r\\n\\\"\\\\r\\\\nDatabase: \\\", database_name,\\r\\n\\\"\\\\r\\\\nQuery hash: \\\", query_hash,\\r\\n\\\"\\\\r\\\\nQuery plan hash: \\\", query_plan_hash,\\r\\n\\\"\\\\r\\\\nAverage impact (%): \\\", avg_user_impact,\\r\\n\\\"\\\\r\\\\nSeeks: \\\", user_seeks,\\r\\n\\\"\\\\r\\\\nScans: \\\", user_scans,\\r\\n\\\"\\\\r\\\\nLast seek time (UTC): \\\", iif(isnotempty(last_user_seek_utc), format_datetime(last_user_seek_utc, \\\"yyyy-MM-dd HH:mm:ss.fff\\\"), \\\"N/A\\\"),\\r\\n\\\"\\\\r\\\\nLast scan time (UTC): \\\", iif(isnotempty(last_user_scan_utc), format_datetime(last_user_scan_utc, \\\"yyyy-MM-dd HH:mm:ss.fff\\\"), \\\"N/A\\\"),\\r\\n\\\"\\\\r\\\\nInterval duration: \\\", strcat(format_timespan(duration_since_startup_seconds, \\\"d\\\"), \\\" days, \\\", format_timespan(duration_since_startup_seconds, \\\"hh\\\"), \\\" hours, \\\", format_timespan(duration_since_startup_seconds, \\\"m\\\"), \\\" minutes\\\"),\\r\\n\\\"\\\\r\\\\n*/\\\",\\r\\n\\\"\\\\r\\\\nCREATE INDEX [replace-with-index-name] ON [\\\", schema_name, \\\"].[\\\", object_name, \\\"]\\\",\\r\\n\\\"\\\\r\\\\n(\\\",\\r\\niif(isnotempty(equality_columns), strcat(\\\"\\\\r\\\\n\\\", equality_columns, iif(isnotempty(inequality_columns), \\\",\\\", \\\"\\\"), \\\" /* equality columns */\\\"), \\\"\\\"),\\r\\niif(isnotempty(inequality_columns), strcat(\\\"\\\\r\\\\n\\\", inequality_columns, \\\" /* inequality columns */\\\"), \\\"\\\"),\\r\\n\\\"\\\\r\\\\n)\\\",\\r\\niif(isnotempty(included_columns), strcat(\\\"\\\\r\\\\nINCLUDE (\\\", included_columns, \\\")\\\"), \\\"\\\"),\\r\\n\\\"\\\\r\\\\nWITH /* Adjust index options as needed */\\\",\\r\\n\\\"\\\\r\\\\n(\\\",\\r\\n\\\"\\\\r\\\\nMAXDOP = 8,\\\",\\r\\n\\\"\\\\r\\\\nONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 5 MINUTES, ABORT_AFTER_WAIT = SELF)),\\\",\\r\\n\\\"\\\\r\\\\n-- RESUMABLE = ON,\\\",\\r\\n\\\"\\\\r\\\\n-- DATA_COMPRESSION = ROW,\\\",\\r\\n\\\"\\\\r\\\\n-- DATA_COMPRESSION = PAGE,\\\",\\r\\n\\\"\\\\r\\\\nSORT_IN_TEMPDB = ON\\\",\\r\\n\\\"\\\\r\\\\n);\\\",\\r\\n\\\"\\\\r\\\\n\\\"\\r\\n)\\r\\n| summarize count_missing_indexes = min_of(count(), max_missing_indexes_per_query_hash),\\r\\n statements = make_list(create_index_statement, max_missing_indexes_per_query_hash) by query_hash\\r\\n| project query_hash,\\r\\n count_missing_indexes,\\r\\n create_index_statements = strcat(\\r\\n\\\"/*\\\",\\r\\n\\\"\\\\r\\\\nIMPORTANT:\\\",\\r\\n\\\"\\\\r\\\\nCREATE INDEX statements in this script are tentative suggestions.\\\",\\r\\n\\\"\\\\r\\\\n\\\\r\\\\nBefore creating indexes based on these suggestions:\\\",\\r\\n\\\"\\\\r\\\\n1. Examine existing indexes. If possible, modify them instead of creating a new index.\\\",\\r\\n\\\"\\\\r\\\\n2. When there are multiple similar index suggestions, consider combining them into one index.\\\",\\r\\n\\\"\\\\r\\\\n3. Always test and validate that a new or modified index does improve performance.\\\",\\r\\n\\\"\\\\r\\\\n\\\\r\\\\nAvoid creating many little-used indexes. That slows down inserts, updates,\\\",\\r\\n\\\"\\\\r\\\\nand deletes substantially, and increases storage and memory consumption.\\\",\\r\\n\\\"\\\\r\\\\n\\\\r\\\\nFor more information, see https://go.microsoft.com/fwlink/?linkid=2245704.\\\",\\r\\n\\\"\\\\r\\\\n*/\\\\r\\\\n\\\\r\\\\n\\\",\\r\\nstrcat_array(statements, \\\"\\\\r\\\\n\\\")\\r\\n)\\r\\n};\\r\\nlet missing_indexes = (\\r\\nunion isfuzzy=true\\r\\n(missing_indexes_stub),\\r\\n(missing_indexes_table)\\r\\n);\\r\\n// The sample to be displayed\\r\\nlet current_snapshot = materialize(\\r\\nsqldb_database_active_sessions\\r\\n| where sample_time_utc == todatetime(\\\"{activitySampleTime}\\\")\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| project-away logical_server_name, database_name, logical_database_id, physical_database_id, replica_type\\r\\n| extend blocking_session_id = iif(\\r\\n blocking_session_id in (0, -4, -5), // Do not treat long latch waits as relevant blocking\\r\\n int(null),\\r\\n blocking_session_id\\r\\n )\\r\\n);\\r\\n// Blocking-related columns\\r\\nlet b = materialize(\\r\\ncurrent_snapshot\\r\\n| project session_id, request_id, blocking_session_id\\r\\n);\\r\\n// Assumption: blocking chains are at most 9 levels deep. If proven incorrect, introduce additional lookups\\r\\nlet head_blockers = materialize(\\r\\nb\\r\\n| lookup (b | project session_id, blocking_session_id2 = blocking_session_id) on $left.blocking_session_id == $right.session_id\\r\\n| lookup (b | project session_id, blocking_session_id3 = blocking_session_id) on $left.blocking_session_id2 == $right.session_id\\r\\n| lookup (b | project session_id, blocking_session_id4 = blocking_session_id) on $left.blocking_session_id3 == $right.session_id\\r\\n| lookup (b | project session_id, blocking_session_id5 = blocking_session_id) on $left.blocking_session_id4 == $right.session_id\\r\\n| lookup (b | project session_id, blocking_session_id6 = blocking_session_id) on $left.blocking_session_id5 == $right.session_id\\r\\n| lookup (b | project session_id, blocking_session_id7 = blocking_session_id) on $left.blocking_session_id6 == $right.session_id\\r\\n| lookup (b | project session_id, blocking_session_id8 = blocking_session_id) on $left.blocking_session_id7 == $right.session_id\\r\\n| lookup (b | project session_id, blocking_session_id9 = blocking_session_id) on $left.blocking_session_id8 == $right.session_id\\r\\n| project session_id,\\r\\n request_id,\\r\\n head_blocking_session_id = coalesce(\\r\\n blocking_session_id9,\\r\\n blocking_session_id8,\\r\\n blocking_session_id7,\\r\\n blocking_session_id6,\\r\\n blocking_session_id5,\\r\\n blocking_session_id4,\\r\\n blocking_session_id3,\\r\\n blocking_session_id2,\\r\\n blocking_session_id\\r\\n )\\r\\n| where isnotempty(head_blocking_session_id)\\r\\n);\\r\\n// column labels for each grid\\r\\nlet column_labels_string = dynamic(\\r\\n[\\r\\n\\\"session_status\\\",\\\"workload_group_name\\\",\\\"connection_id\\\",\\\"encrypt_option\\\",\\\"wait_resource\\\",\\\"transaction_isolation_level\\\",\\\"query_hash\\\",\\\"query_plan_hash\\\",\\\"session_cpu_time\\\",\\\"session_duration\\\",\\\"request_cpu_time\\\",\\\"sql_module_name\\\"\\r\\n]);\\r\\nlet column_labels_number_count = dynamic(\\r\\n[\\r\\n\\\"session_logical_reads\\\",\\\"session_writes\\\",\\\"session_row_count\\\",\\\"request_row_count\\\",\\\"dop\\\",\\\"parallel_worker_count\\\",\\\"request_writes\\\"\\r\\n]);\\r\\nlet column_labels_number_id = dynamic(\\r\\n[\\r\\n\\\"database_id\\\",\\\"workload_group_id\\\",\\\"request_id\\\",\\\"sql_module_object_id\\\",\\\"blocking_session_id\\\"\\r\\n]);\\r\\nlet column_labels_number_kb = dynamic(\\r\\n[\\r\\n\\\"granted_memory\\\",\\\"requested_memory\\\",\\\"max_used_memory\\\",\\\"ideal_memory\\\"\\r\\n]);\\r\\nlet column_labels_datetime = dynamic(\\r\\n[\\r\\n\\\"login_time\\\",\\\"request_start_time\\\"\\r\\n]);\\r\\nlet column_labels_task_counts = dynamic(\\r\\n[\\r\\n\\\"pending\\\", \\\"runnable\\\", \\\"running\\\", \\\"suspended\\\", \\\"done\\\", \\\"spinloop\\\"\\r\\n]);\\r\\n// result set for strings grid\\r\\nlet session_details_string = (\\r\\ncurrent_snapshot\\r\\n| project session_id, request_id, session_status, workload_group_name, connection_id, encrypt_option, wait_resource, transaction_isolation_level, query_hash, query_plan_hash, session_cpu_time = format_timespan(session_cpu_time_ms * 1ms, \\\"d.hh:mm:ss.fff\\\"), session_duration = format_timespan(session_total_elapsed_time_ms * 1ms, \\\"d.hh:mm:ss.fff\\\"), request_cpu_time = format_timespan(request_cpu_time_ms * 1ms, \\\"d.hh:mm:ss.fff\\\"), sql_module_name\\r\\n| project session_id, request_id, columns = pack_all() // put all columns into a property bag\\r\\n| mv-apply column_label = column_labels_string to typeof(string) on (project column_label, column_value = tostring(columns[column_label])) // create a row for each name/value pair\\r\\n| project-away columns\\r\\n| sort by column_label asc //make_list later will preserve sort order\\r\\n| project session_id, request_id, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value) // introduce \\\"Property\\\" and \\\"Value\\\" column names\\r\\n| summarize details_string = dynamic_to_json(make_list(c)) by session_id, request_id // for each session_id and request_id, aggregate rowset into a json array of rows, to be used as grid source\\r\\n);\\r\\n// result set for count numbers grid\\r\\nlet session_details_number_count = (\\r\\ncurrent_snapshot\\r\\n| project session_id, request_id, session_logical_reads, session_writes, session_row_count, request_row_count, dop, parallel_worker_count, request_writes\\r\\n| project session_id, request_id, columns = pack_all()\\r\\n| mv-apply column_label = column_labels_number_count to typeof(string) on (project column_label, column_value = tolong(columns[column_label]))\\r\\n| project-away columns\\r\\n| sort by column_label asc\\r\\n| project session_id, request_id, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value)\\r\\n| summarize details_number_count = dynamic_to_json(make_list(c)) by session_id, request_id\\r\\n);\\r\\n// result set for id numbers grid\\r\\nlet session_details_number_id = (\\r\\ncurrent_snapshot\\r\\n| project session_id, request_id, database_id, workload_group_id, sql_module_object_id, blocking_session_id\\r\\n| project session_id, request_id, columns = pack_all()\\r\\n| mv-apply column_label = column_labels_number_id to typeof(string) on (project column_label, column_value = tolong(columns[column_label]))\\r\\n| project-away columns\\r\\n| sort by column_label asc\\r\\n| project session_id, request_id, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value)\\r\\n| summarize details_number_id = dynamic_to_json(make_list(c)) by session_id, request_id\\r\\n);\\r\\n// result set for byte numbers grid\\r\\nlet session_details_number_kb = (\\r\\ncurrent_snapshot\\r\\n| project session_id, request_id, granted_memory = memory_grant_kb, requested_memory = requested_memory_kb, max_used_memory = max_used_memory_kb, ideal_memory = ideal_memory_kb\\r\\n| project session_id, request_id, columns = pack_all()\\r\\n| mv-apply column_label = column_labels_number_kb to typeof(string) on (project column_label, column_value = tolong(columns[column_label]))\\r\\n| project-away columns\\r\\n| sort by column_label asc\\r\\n| project session_id, request_id, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value)\\r\\n| summarize details_number_kb = dynamic_to_json(make_list(c)) by session_id, request_id\\r\\n);\\r\\n// result set for datetime grid\\r\\nlet session_details_datetime = (\\r\\ncurrent_snapshot\\r\\n| project session_id, request_id, login_time, request_start_time\\r\\n| project session_id, request_id, columns = pack_all()\\r\\n| mv-apply column_label = column_labels_datetime to typeof(string) on (project column_label, column_value = todatetime(columns[column_label]))\\r\\n| project-away columns\\r\\n| sort by column_label asc\\r\\n| project session_id, request_id, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value)\\r\\n| summarize details_datetime = dynamic_to_json(make_list(c)) by session_id, request_id\\r\\n);\\r\\nlet session_details_task_counts = ( \\r\\ncurrent_snapshot\\r\\n| project session_id, request_id, pending = pending_task_count, runnable = runnable_task_count, running = running_task_count, suspended = suspended_task_count, done = done_task_count, spinloop = spinloop_task_count\\r\\n| project session_id, request_id, columns = pack_all()\\r\\n| mv-apply column_label = column_labels_task_counts to typeof(string) on (project column_label, column_value = toint(columns[column_label]))\\r\\n| project-away columns\\r\\n| sort by column_label asc\\r\\n| project session_id, request_id, c = pack(\\\"Task type\\\", column_label, \\\"Count\\\", column_value)\\r\\n| summarize task_counts = dynamic_to_json(make_list(c)) by session_id, request_id\\r\\n);\\r\\n// return last snapshot with json arrays for each detail grid\\r\\ncurrent_snapshot\\r\\n| lookup head_blockers on $left.session_id == $right.session_id and $left.request_id == $right.request_id\\r\\n| join session_details_string on session_id and $left.request_id == $right.request_id\\r\\n| join session_details_number_count on session_id and $left.request_id == $right.request_id\\r\\n| join session_details_number_id on session_id and $left.request_id == $right.request_id\\r\\n| join session_details_number_kb on session_id and $left.request_id == $right.request_id\\r\\n| join session_details_datetime on session_id and $left.request_id == $right.request_id\\r\\n| join session_details_task_counts on session_id and $left.request_id == $right.request_id\\r\\n| join kind=leftouter (\\r\\n head_blockers\\r\\n | summarize count_blocked_sessions = count() by head_blocking_session_id\\r\\n ) on $left.session_id == $right.head_blocking_session_id\\r\\n| lookup missing_indexes on query_hash\\r\\n| project request_duration = format_timespan(1ms * request_total_elapsed_time_ms, \\\"d.hh:mm:ss.fff\\\"),\\r\\n session_id,\\r\\n request_status,\\r\\n command,\\r\\n input_buffer_text,\\r\\n blocked_by = head_blocking_session_id,\\r\\n count_blocked_sessions,\\r\\n count_missing_indexes,\\r\\n request_normalized_cpu_time = toreal(request_cpu_time_ms) / toreal(request_total_elapsed_time_ms),\\r\\n request_normalized_logical_reads = toreal(request_logical_reads) / toreal(request_total_elapsed_time_ms),\\r\\n dop,\\r\\n wait_type,\\r\\n wait_time = format_timespan(1ms * iif(wait_time_ms != 0, wait_time_ms, int(null)), \\\"d.hh:mm:ss.fff\\\"),\\r\\n open_transaction_count,\\r\\n transaction_duration_ms = datetime_diff(\\\"millisecond\\\", sample_time_utc, transaction_begin_time_utc),\\r\\n transaction_log_bytes_used,\\r\\n request_id,\\r\\n percent_complete = iif(percent_complete == 0, real(null), percent_complete),\\r\\n tempdb_allocations_kb,\\r\\n tempdb_current_kb,\\r\\n sql_module_name,\\r\\n login_name,\\r\\n host_name,\\r\\n program_name,\\r\\n client_net_address,\\r\\n request_cpu_time = format_timespan(1ms * request_cpu_time_ms, \\\"d.hh:mm:ss.fff\\\"),\\r\\n request_total_elapsed_time_ms,\\r\\n request_logical_reads,\\r\\n statement_text_json = dynamic_to_json(pack(\\\"statement_text\\\", statement_text)),\\r\\n input_buffer_text_json = dynamic_to_json(pack(\\\"input_buffer_text\\\", input_buffer_text)),\\r\\n session_wait_stats = iif(isempty(session_wait_stats), '[{\\\"wait_type\\\":\\\"\\\",\\\"wait_time_ms\\\":\\\"\\\",\\\"signal_wait_time_ms\\\":\\\"\\\",\\\"max_wait_time_ms\\\":\\\"\\\",\\\"waiting_tasks_count\\\":\\\"\\\"}]', session_wait_stats),\\r\\n details_datetime,\\r\\n details_number_id,\\r\\n details_number_kb,\\r\\n details_string,\\r\\n details_number_count,\\r\\n task_counts,\\r\\n create_index_statements,\\r\\n blocked_tooltip_text = iif(isnull(head_blocking_session_id), \\\"\\\", strcat(\\\"Session \\\", tostring(session_id), \\\" is blocked. The head blocker of the blocking chain is session \\\", tostring(head_blocking_session_id), \\\".\\\")),\\r\\n blocker_tooltip_text = iif(count_blocked_sessions > 0, strcat(\\\"Session \\\", session_id, \\\" is a head blocker in a blocking chain. It blocks \\\", count_blocked_sessions, \\\" other session(s).\\\"), \\\"\\\")\\r\\n| extend request_normalized_cpu_time = iif(isfinite(request_normalized_cpu_time), request_normalized_cpu_time, real(null)),\\r\\n request_normalized_logical_reads = iif(isfinite(request_normalized_logical_reads), request_normalized_logical_reads, real(null))\\r\\n| where \\\"{blockedFilter}\\\" == \\\"all\\\"\\r\\n or\\r\\n (\\\"{blockedFilter}\\\" == \\\"blocked\\\" and (isnotnull(blocked_by) or isnotnull(count_blocked_sessions)))\\r\\n| sort by count_blocked_sessions desc nulls last, request_total_elapsed_time_ms desc nulls last // blockers first, followed by sessions with longest running requests, then longest running sessions\\r\\n\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"size": 0,
"showAnalytics": true,
"title": "Active sessions",
"noDataMessage": "There is no data for specified parameters.",
"exportedParameters": [
{
"fieldName": "session_wait_stats",
"parameterName": "session_wait_stats",
"parameterType": 1,
"defaultValue": "[{\"wait_type\":\"\",\"wait_time_ms\":\"\",\"signal_wait_time_ms\":\"\",\"max_wait_time_ms\":\"\",\"waiting_tasks_count\":\"\"}]"
},
{
"fieldName": "task_counts",
"parameterName": "task_counts",
"parameterType": 1,
"defaultValue": "[{\"Task type\":\"\",\"Count\":\"\"}]"
},
{
"fieldName": "details_string",
"parameterName": "details_string",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_number_count",
"parameterName": "details_number_count",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_number_id",
"parameterName": "details_number_id",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_number_kb",
"parameterName": "details_number_kb",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_datetime",
"parameterName": "details_datetime",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "statement_text_json",
"parameterName": "statement_text",
"parameterType": 1,
"defaultValue": "\"\""
},
{
"fieldName": "input_buffer_text_json",
"parameterName": "input_buffer_text",
"parameterType": 1,
"defaultValue": "\"\""
}
],
"showExportToExcel": true,
"queryType": 9,
"visualization": "table",
"gridSettings": {
"formatters": [
{
"columnMatch": "request_duration",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "20ch"
}
},
{
"columnMatch": "session_id",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "14ch"
}
},
{
"columnMatch": "request_status",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "colors",
"thresholdsGrid": [
{
"operator": "==",
"thresholdValue": "background",
"representation": "orange",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "running",
"representation": "greenDark",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "runnable",
"representation": "green",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "sleeping",
"representation": "gray",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "suspended",
"representation": "yellow",
"text": "{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"text": "{0}{1}"
}
],
"customColumnWidthSetting": "13ch"
}
},
{
"columnMatch": "command",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "colors",
"thresholdsGrid": [
{
"operator": "startsWith",
"thresholdValue": "SELECT",
"representation": "lightBlue",
"text": "{0}{1}"
},
{
"operator": "startsWith",
"thresholdValue": "INSERT",
"representation": "orange",
"text": "{0}{1}"
},
{
"operator": "startsWith",
"thresholdValue": "UPDATE",
"representation": "orange",
"text": "{0}{1}"
},
{
"operator": "startsWith",
"thresholdValue": "DELETE",
"representation": "orange",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "EXECUTE",
"representation": "grayBlue",
"text": "{0}{1}"
},
{
"operator": "startsWith",
"thresholdValue": "MERGE",
"representation": "orange",
"text": "{0}{1}"
},
{
"operator": "==",
"thresholdValue": "CREATE INDEX",
"representation": "turquoise",
"text": "{0}{1}"
},
{
"operator": "startsWith",
"thresholdValue": "COMMIT",
"representation": "green",
"text": "{0}{1}"
},
{
"operator": "contains",
"thresholdValue": "ROLLBACK",
"representation": "red",
"text": "{0}{1}"
},
{
"operator": "startsWith",
"thresholdValue": "DBCC",
"representation": "purple",
"text": "{0}{1}"
},
{
"operator": "startsWith",
"thresholdValue": "BACKUP",
"representation": "yellow",
"text": "{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"text": "{0}{1}"
}
],
"customColumnWidthSetting": "15ch"
},
"tooltipFormat": {
"tooltip": "[\"command\"]"
}
},
{
"columnMatch": "input_buffer_text",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "30ch"
}
},
{
"columnMatch": "blocked_by",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "colors",
"thresholdsGrid": [
{
"operator": "!=",
"thresholdValue": "0",
"representation": null,
"text": "⌛{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"representation": null,
"text": "{0}{1}"
}
],
"customColumnWidthSetting": "15ch"
},
"tooltipFormat": {
"tooltip": "[\"blocked_tooltip_text\"]"
}
},
{
"columnMatch": "count_blocked_sessions",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "colors",
"thresholdsGrid": [
{
"operator": ">",
"thresholdValue": "0",
"representation": null,
"text": "⛔{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"representation": null,
"text": "{0}{1}"
}
],
"customColumnWidthSetting": "12ch"
},
"tooltipFormat": {
"tooltip": "[\"blocker_tooltip_text\"]"
}
},
{
"columnMatch": "count_missing_indexes",
"formatter": 18,
"formatOptions": {
"linkTarget": "WorkbookTemplate",
"linkIsContextBlade": true,
"thresholdsOptions": "colors",
"thresholdsGrid": [
{
"operator": ">",
"thresholdValue": "0",
"representation": null,
"text": "⚡{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"representation": null,
"text": "{0}{1}"
}
],
"workbookContext": {
"componentIdSource": "parameter",
"componentId": "watcherResourceId",
"resourceIdsSource": "workbook",
"templateIdSource": "static",
"templateId": "Community-Workbooks/Database watcher/SQL text",
"typeSource": "workbook",
"gallerySource": "static",
"gallery": "microsoft.database-watcher",
"locationSource": "workbook",
"workbookName": "Index suggestions",
"passSpecificParams": true,
"templateParameters": [
{
"name": "sqlText",
"source": "column",
"value": "create_index_statements"
}
]
},
"customColumnWidthSetting": "21ch"
},
"tooltipFormat": {
"tooltip": "View index suggestions"
}
},
{
"columnMatch": "request_normalized_cpu_time",
"formatter": 8,
"formatOptions": {
"palette": "magenta",
"customColumnWidthSetting": "12ch"
},
"numberFormat": {
"unit": 23,
"options": {
"style": "decimal",
"useGrouping": true
}
},
"tooltipFormat": {
"tooltip": "Normalized request CPU time. Shows higher values for top CPU consumers. Calculated as the ratio of actual request CPU time consumed so far ([\"request_cpu_time\"]) to the request elapsed time ([\"request_duration\"])."
}
},
{
"columnMatch": "request_normalized_logical_reads",
"formatter": 8,
"formatOptions": {
"palette": "lightBlue",
"customColumnWidthSetting": "17ch"
},
"numberFormat": {
"unit": 17,
"options": {
"style": "decimal",
"useGrouping": true
}
},
"tooltipFormat": {
"tooltip": "Normalized request logical reads. Shows higher values for top logical read consumers. Calculated as the ratio of actual request logical reads consumed so far ([\"request_logical_reads\"]) to the request elapsed time ([\"request_duration\"]) in milliseconds."
}
},
{
"columnMatch": "dop",
"formatter": 8,
"formatOptions": {
"min": 1,
"max": 8,
"palette": "orange"
},
"tooltipFormat": {
"tooltip": "Degree of parallelism"
}
},
{
"columnMatch": "wait_type",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "24ch"
}
},
{
"columnMatch": "wait_time",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "18ch"
}
},
{
"columnMatch": "open_transaction_count",
"formatter": 2,
"formatOptions": {
"customColumnWidthSetting": "22ch"
}
},
{
"columnMatch": "transaction_duration_ms",
"formatter": 8,
"formatOptions": {
"palette": "turquoise",
"customColumnWidthSetting": "24ch"
},
"numberFormat": {
"unit": 23,
"options": {
"style": "decimal",
"useGrouping": true
}
},
"tooltipFormat": {
"tooltip": "Transaction duration at the time when the displayed sample is collected"
}
},
{
"columnMatch": "transaction_log_bytes_used",
"formatter": 8,
"formatOptions": {
"palette": "greenDark",
"customColumnWidthSetting": "28ch"
},
"numberFormat": {
"unit": 2,
"options": {
"style": "decimal",
"useGrouping": true
}
},
"tooltipFormat": {
"tooltip": "The total amount of log generated by the transaction"
}
},
{
"columnMatch": "request_id",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "15ch"
}
},
{
"columnMatch": "percent_complete",
"formatter": 4,
"formatOptions": {
"min": 0,
"max": 100,
"palette": "blue",
"customColumnWidthSetting": "16ch"
},
"numberFormat": {
"unit": 1,
"options": {
"style": "decimal"
}
}
},
{
"columnMatch": "tempdb_allocations_kb",
"formatter": 2,
"formatOptions": {
"customColumnWidthSetting": "22ch"
},
"numberFormat": {
"unit": 3,
"options": {
"style": "decimal",
"useGrouping": true
}
}
},
{
"columnMatch": "tempdb_current_kb",
"formatter": 2,
"formatOptions": {
"customColumnWidthSetting": "19ch"
},
"numberFormat": {
"unit": 3,
"options": {
"style": "decimal",
"useGrouping": true
}
}
},
{
"columnMatch": "program_name",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "30ch"
}
},
{
"columnMatch": "client_net_address",
"formatter": 0,
"formatOptions": {
"customColumnWidthSetting": "22ch"
}
},
{
"columnMatch": "request_cpu_time",
"formatter": 5
},
{
"columnMatch": "request_total_elapsed_time_ms",
"formatter": 5
},
{
"columnMatch": "request_logical_reads",
"formatter": 5
},
{
"columnMatch": "statement_text_json",
"formatter": 5
},
{
"columnMatch": "input_buffer_text_json",
"formatter": 5
},
{
"columnMatch": "session_wait_stats",
"formatter": 5
},
{
"columnMatch": "details_datetime",
"formatter": 5
},
{
"columnMatch": "details_number_id",
"formatter": 5
},
{
"columnMatch": "details_number_kb",
"formatter": 5
},
{
"columnMatch": "details_string",
"formatter": 5
},
{
"columnMatch": "details_number_count",
"formatter": 5
},
{
"columnMatch": "task_counts",
"formatter": 5
},
{
"columnMatch": "create_index_statements",
"formatter": 5
},
{
"columnMatch": "blocked_tooltip_text",
"formatter": 5
},
{
"columnMatch": "blocker_tooltip_text",
"formatter": 5
}
],
"filter": true,
"labelSettings": [
{
"columnId": "request_duration",
"label": "Request duration"
},
{
"columnId": "session_id",
"label": "Session ID"
},
{
"columnId": "request_status",
"label": "Status"
},
{
"columnId": "command",
"label": "Command"
},
{
"columnId": "input_buffer_text",
"label": "Input buffer"
},
{
"columnId": "blocked_by",
"label": "Blocked by"
},
{
"columnId": "count_blocked_sessions",
"label": "Blocker"
},
{
"columnId": "count_missing_indexes",
"label": "Index suggestions"
},
{
"columnId": "request_normalized_cpu_time",
"label": "CPU"
},
{
"columnId": "request_normalized_logical_reads",
"label": "Logical reads"
},
{
"columnId": "dop",
"label": "DOP"
},
{
"columnId": "wait_type",
"label": "Wait type"
},
{
"columnId": "wait_time",
"label": "Wait time"
},
{
"columnId": "open_transaction_count",
"label": "Open transactions"
},
{
"columnId": "transaction_duration_ms",
"label": "Transaction duration"
},
{
"columnId": "transaction_log_bytes_used",
"label": "Transaction log space used"
},
{
"columnId": "request_id",
"label": "Request ID"
},
{
"columnId": "percent_complete",
"label": "% complete"
},
{
"columnId": "tempdb_allocations_kb",
"label": "Tempdb allocations"
},
{
"columnId": "tempdb_current_kb",
"label": "Tempdb current"
},
{
"columnId": "sql_module_name",
"label": "Module"
},
{
"columnId": "login_name",
"label": "Login"
},
{
"columnId": "host_name",
"label": "Host"
},
{
"columnId": "program_name",
"label": "Program"
},
{
"columnId": "client_net_address",
"label": "Client net address"
}
]
}
},
"conditionalVisibility": {
"parameterName": "activitySampleTime",
"comparison": "isNotEqualTo"
},
"name": "active_sessions"
},
{
"type": 1,
"content": {
"json": "The grid shows a snapshot of active user sessions in this database at a point in time. Snapshots are collected at regular intervals defined by `Active Sessions` dataset configuration. A session is considered active if it is running a request (for example, executing a query), has an open transaction, or is blocking other sessions. Click on a session in the grid to view session details, including SQL query text, session waits, etc.\r\n\r\nData is collected from [sys.dm_exec_connections](https://go.microsoft.com/fwlink/?linkid=2214209), [sys.dm_exec_sessions](https://go.microsoft.com/fwlink/?linkid=2213978) [sys.dm_exec_requests](https://go.microsoft.com/fwlink/?linkid=2214068), [sys.dm_exec_session_wait_stats](https://go.microsoft.com/fwlink/?linkid=2214069), and other views."
},
"conditionalVisibilities": [
{
"parameterName": "showDescriptions",
"comparison": "isEqualTo",
"value": "true"
},
{
"parameterName": "activitySampleTime",
"comparison": "isNotEqualTo"
}
],
"name": "activity_help"
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"title": "Selected session details",
"expandable": true,
"expanded": true,
"items": [
{
"type": 11,
"content": {
"version": "LinkItem/1.0",
"style": "tabs",