forked from DavidWiseman/sqlserver-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoTuneMonitor.sql
84 lines (81 loc) · 1.97 KB
/
AutoTuneMonitor.sql
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
/*
https://jasonbrimhall.info/2019/01/04/automatic-tuning-monitoring-and-diagnostics/
Author: Jason Brimhall
*/
USE master;
GO
-- Create the Event Session
IF EXISTS
(
SELECT *
FROM sys.server_event_sessions
WHERE name = 'AutoTuneMonitor'
)
DROP EVENT SESSION AutoTuneMonitor ON SERVER;
GO
CREATE EVENT SESSION [AutoTuneMonitor]
ON SERVER
ADD EVENT qds.automatic_tuning_config_change
(ACTION
(
sqlserver.database_id,
sqlserver.nt_username,
sqlserver.sql_text,
sqlserver.username,
sqlserver.session_nt_username,
sqlserver.client_app_name,
sqlserver.session_id,
sqlserver.client_hostname
)
),
ADD EVENT qds.automatic_tuning_diagnostics
(ACTION
(
sqlserver.database_id,
sqlserver.nt_username,
sqlserver.sql_text,
sqlserver.username,
sqlserver.session_nt_username,
sqlserver.client_app_name,
sqlserver.session_id,
sqlserver.client_hostname
)
),
ADD EVENT qds.automatic_tuning_state_change
(ACTION
(
sqlserver.database_id,
sqlserver.nt_username,
sqlserver.sql_text,
sqlserver.username,
sqlserver.session_nt_username,
sqlserver.client_app_name,
sqlserver.session_id,
sqlserver.client_hostname
)
),
ADD EVENT qds.automatic_tuning_error
(ACTION
(
sqlserver.database_id,
sqlserver.nt_username,
sqlserver.sql_text,
sqlserver.username,
sqlserver.session_nt_username,
sqlserver.client_app_name,
sqlserver.session_id,
sqlserver.client_hostname
)
)
ADD TARGET package0.event_file
(SET filename = N'C:\XE\AutoTuneMonitor.xel'),
ADD TARGET package0.ring_buffer
WITH
(
MAX_DISPATCH_LATENCY = 5 SECONDS,
TRACK_CAUSALITY = ON,
STARTUP_STATE = OFF
);
GO
ALTER EVENT SESSION [AutoTuneMonitor] ON SERVER STATE = START;
GO