Last active
October 12, 2023 20:30
-
-
Save gwalkey/5628793ed34ad1b5d54ed1a1a92f4780 to your computer and use it in GitHub Desktop.
SQL Server Extended Events Sessions - DBA Pack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Blocked Process Report | |
CREATE EVENT SESSION [Blocked Process Report] ON SERVER | |
ADD EVENT sqlserver.blocked_process_report | |
ADD TARGET package0.event_file(SET filename=N'd:\Traces\Blocked-Process-Report.xel',max_file_size=(1024),max_rollover_files=(4)) | |
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=120 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON) | |
GO | |
-- Deadlocks | |
CREATE EVENT SESSION [deadlock_capture] ON SERVER | |
ADD EVENT sqlserver.database_xml_deadlock_report( | |
ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_name,sqlserver.server_principal_name,sqlserver.session_nt_username,sqlserver.sql_text)) | |
ADD TARGET package0.event_file(SET filename=N'd:\traces\deadlock_capture.xel') | |
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) | |
GO | |
--- Failed Logins | |
CREATE EVENT SESSION [Failed Logins] ON SERVER | |
ADD EVENT sqlserver.error_reported( | |
ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_id,sqlserver.database_name,sqlserver.nt_username,sqlserver.server_instance_name,sqlserver.session_nt_username,sqlserver.username) | |
WHERE ([package0].[equal_int64]([severity],(14)) AND [error_number]=(18456) OR [error_number]=(18452) OR [error_number]=(17806))) | |
ADD TARGET package0.event_file(SET filename=N'd:\traces\XE_Failed_Logins.xel',max_file_size=(100),max_rollover_files=(100)) | |
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON) | |
GO | |
--- Good Logins | |
CREATE EVENT SESSION [Logins] ON SERVER | |
ADD EVENT sqlserver.login(SET collect_database_name=(1) | |
ACTION(package0.collect_system_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_id,sqlserver.database_name,sqlserver.nt_username,sqlserver.server_instance_name,sqlserver.session_nt_username,sqlserver.username) | |
WHERE ([sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[client_app_name],N'Microsoft SQL Server Management Studio - Transact-SQL IntelliSense') AND NOT [sqlserver].[like_i_sql_unicode_string]([sqlserver].[client_app_name],N'SQLAgent%'))) | |
ADD TARGET package0.event_file(SET filename=N'd:\traces\XE_Logins.xel',max_file_size=(100),max_rollover_files=(100)) | |
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON) | |
GO | |
--- File Growths to Ring Buffer | |
CREATE EVENT SESSION [File_Growths_Ring_Buffer] ON SERVER | |
ADD EVENT sqlserver.database_file_size_change( ACTION(package0.collect_system_time,sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_id,sqlserver.database_name,sqlserver.nt_username,sqlserver.session_nt_username,sqlserver.sql_text)) | |
ADD TARGET package0.ring_buffer | |
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON) | |
GO | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment