GUI:
SSMS --> Management --> Extented Events --> Sessions --> 1. AlwaysOn_Health 2.system_health
a Wizard,
an Extended Events Properties Editor,
a Data Viewer.
right-click the session
and select Stop Session from the context menu.
Right-click the Session again and select Properties, and the Editor opens,
For different types of Events, Targets, Filters, and Actions.
to configure those events with Actions, Filters, and Event Fields.
gui tools for extended event
video on youtube
CREATE EVENT SESSION [system_health] ON SERVER
ADD EVENT sqlclr.clr_allocation_failure(
ACTION(package0.callstack,sqlserver.session_id)),
ADD EVENT sqlclr.clr_virtual_alloc_failure(
ACTION(package0.callstack,sqlserver.session_id)),
ADD EVENT sqlos.memory_broker_ring_buffer_recorded,
ADD EVENT sqlos.memory_node_oom_ring_buffer_recorded(
ACTION(package0.callstack,sqlserver.session_id,sqlserver.sql_text,sqlserver.tsql_stack)),
ADD EVENT sqlos.scheduler_monitor_deadlock_ring_buffer_recorded,
ADD EVENT sqlos.scheduler_monitor_non_yielding_iocp_ring_buffer_recorded,
ADD EVENT sqlos.scheduler_monitor_non_yielding_ring_buffer_recorded,
ADD EVENT sqlos.scheduler_monitor_non_yielding_rm_ring_buffer_recorded,
ADD EVENT sqlos.scheduler_monitor_stalled_dispatcher_ring_buffer_recorded,
ADD EVENT sqlos.scheduler_monitor_system_health_ring_buffer_recorded,
ADD EVENT sqlos.wait_info(
ACTION(package0.callstack,sqlserver.session_id,sqlserver.sql_text)
WHERE ([duration]>(15000) AND
([wait_type]>(31) AND
([wait_type]>(47) AND [wait_type]<(54)
OR [wait_type]<(38)
OR [wait_type]>(63) AND [wait_type]<(70)
OR [wait_type]>(96) AND [wait_type]<(100)
OR [wait_type]=(107)
OR [wait_type]=(113)
OR [wait_type]>(174) AND [wait_type]<(179)
OR [wait_type]=(186)
OR [wait_type]=(207)
OR [wait_type]=(269)
OR [wait_type]=(283)
OR [wait_type]=(284))
OR [duration]>(30000) AND [wait_type]<(22)))),
ADD EVENT sqlos.wait_info_external(
ACTION(package0.callstack,sqlserver.session_id,sqlserver.sql_text)
WHERE ([duration]>(5000) AND ([wait_type]>(365) AND [wait_type]<(372)
OR [wait_type]>(372) AND [wait_type]<(377)
OR [wait_type]>(377) AND [wait_type]<(383)
OR [wait_type]>(420) AND [wait_type]<(424)
OR [wait_type]>(426) AND [wait_type]<(432)
OR [wait_type]>(432) AND [wait_type]<(435)
OR [duration]>(45000) AND ([wait_type]>(382) AND [wait_type]<(386)
OR [wait_type]>(423) AND [wait_type]<(427)
OR [wait_type]>(434) AND [wait_type]<(437)
OR [wait_type]>(442) AND [wait_type]<(451)
OR [wait_type]>(451) AND [wait_type]<(473)
OR [wait_type]>(484) AND [wait_type]<(499)
OR [wait_type]=(365)
OR [wait_type]=(372)
OR [wait_type]=(377)
OR [wait_type]=(387)
OR [wait_type]=(432)
OR [wait_type]=(502))))),
ADD EVENT sqlserver.connectivity_ring_buffer_recorded(SET collect_call_stack=(1)),
ADD EVENT sqlserver.error_reported(
ACTION(package0.callstack,sqlserver.database_id,sqlserver.session_id,sqlserver.sql_text,sqlserver.tsql_stack)
WHERE ([severity]>=(20)
OR ([error_number]=(17803)
OR [error_number]=(701)
OR [error_number]=(802)
OR [error_number]=(8645)
OR [error_number]=(8651)
OR [error_number]=(8657)
OR [error_number]=(8902)))),
ADD EVENT sqlserver.security_error_ring_buffer_recorded(SET collect_call_stack=(1)),
ADD EVENT sqlserver.sp_server_diagnostics_component_result(SET collect_data=(1)
WHERE ([sqlserver].[is_system]=(1) AND [component]<>(4))),
ADD EVENT sqlserver.xml_deadlock_report
ADD TARGET package0.event_file(SET filename=N'system_health.xel',max_file_size=(5),max_rollover_files=(4)),
ADD TARGET package0.ring_buffer(SET max_events_limit=(5000),max_memory=(4096))
WITH (MAX_MEMORY=4096 KB,
EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,
MAX_DISPATCH_LATENCY=120
SECONDS,
MAX_EVENT_SIZE=0KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF)
GO
-- ------------------------------------------------------------------------------
The Extended Event GUI
http://jasonbrimhall.info/2015/09/25/the-extended-event-gui/
https://blogs.msdn.microsoft.com/extended_events/
https://www.mssqltips.com/sqlservertip/2731/managing-sql-server-extended-events-in-management-studio/
https://www.mssqltips.com/sql-server-tip-category/99/extended-events/
-- ------------------------------------------------------------------------------
Brent Ozar On extended events
The following only available in extended event, not in profiler
1. Availability Groups: Track when a replica's state changes
2. BUffer Pool Extensions: Track when pages are read or evicted, Track the PLE
3. Columnstore Indexes: Count reads and readaheads
4. Filestream: See access requests - and failures
5. In-Memory OLTP
6. Windows Azure Storage: Reads complete - or fail
7. async_io request
8. checkpoint
9. latch
CREATE EVENT SESSION [Query Performance Metrics] ON SERVER
ADD EVENT sqlserver.rpc_completed
GO
CREATE EVENT SESSION blocked_process_test ON SERVER
ADD EVENT sqlserver.blocked_process_report
CREATE EVENT SESSION waits ON SERVER
ADD EVENT sqlos.wait_info (
WHERE (sqlserver.session_id = 58))
ADD TARGET package0.event_file
(SET FILENAME = 'C:\data\waits.xel')
ALTER EVENT SESSION waits ON SERVER STATE = START
GO
ALTER EVENT SESSION waits ON SERVER STATE = STOP
SELECT *, CAST(event_data AS XML) AS 'event_data'
FROM sys.fn_xe_file_target_read_file('C:\data\waits*.xel', NULL, NULL, NULL)
CREATE TABLE #waits (
event_data XML)
GO
INSERT INTO #waits (event_data)
SELECT CAST (event_data AS XML) AS event_data
FROM sys.fn_xe_file_target_read_file (
'C:\data\waits*.xel', NULL, NULL, NULL)
-- -------------------------------------------
SELECT
waits.wait_type,
COUNT (*) AS wait_count,
SUM (waits.duration) AS total_wait_time_ms,
SUM (waits.duration) - SUM (waits.signal_duration) AS total_resource_wait_time_ms,
SUM (waits.signal_duration) AS total_signal_wait_time_ms
FROM
(SELECT
event_data.value ('(/event/@timestamp)[1]', 'DATETIME') AS datetime,
event_data.value ('(/event/data[@name=''wait_type'']/text)[1]', 'VARCHAR(100)') AS wait_type,
event_data.value ('(/event/data[@name=''opcode'']/text)[1]', 'VARCHAR(100)') AS opcode,
event_data.value ('(/event/data[@name=''duration'']/value)[1]', 'BIGINT') AS duration,
event_data.value ('(/event/data[@name=''signal_duration'']/value)[1]', 'BIGINT') AS signal_duration
FROM #waits
) AS waits
WHERE waits.opcode = 'End'
GROUP BY waits.wait_type
ORDER BY total_wait_time_ms DESC
DROP EVENT SESSION waits ON SERVER
-- ------------------------------------------------
An Extended Events session
sql central
technet
|