forked from ktaranov/sqlserver-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConvertingSQLTracetoExtendedEvents.sql
325 lines (324 loc) · 16 KB
/
ConvertingSQLTracetoExtendedEvents.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
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
/*
Author: Jonathan Kehayias
Original link: https://www.sqlskills.com/blogs/jonathan/converting-sql-trace-to-extended-events-in-sql-server-2012
*/
IF EXISTS (SELECT 1 FROM sys.server_event_sessions WHERE name = 'XE_Default_Trace')
DROP EVENT SESSION [XE_Default_Trace] ON SERVER;
GO
CREATE EVENT SESSION [XE_Default_Trace]
ON SERVER
/* Audit Login Failed is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Database Scope GDR Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Schema Object GDR Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Addlogin Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Login GDR Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Login Change Property Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Add Login to Server Role Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Add DB User Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Add Member to DB Role Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Add Role Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Backup/Restore Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit DBCC Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Change Audit Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Change Database Owner is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Schema Object Take Ownership Event is not implemented in Extended Events it may be a Server Audit Event */
/* Audit Server Alter Trace Event is not implemented in Extended Events it may be a Server Audit Event */
ADD EVENT sqlserver.database_file_size_change(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
)
),
/* Log File Auto Grow is implemented as the sqlserver.database_file_size_change event in Extended Events */
/* Data File Auto Shrink is implemented as the sqlserver.database_file_size_change event in Extended Events */
/* Log File Auto Shrink is implemented as the sqlserver.database_file_size_change event in Extended Events */
ADD EVENT sqlserver.database_mirroring_state_change(
ACTION
(
package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
)
),
ADD EVENT sqlserver.errorlog_written(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, sqlserver.database_id — DatabaseID from SQLTrace
, sqlserver.database_name — DatabaseName from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
— Severity not implemented in XE for this event
— State not implemented in XE for this event
— Error not implemented in XE for this event
)
),
ADD EVENT sqlserver.full_text_crawl_started(
ACTION
(
package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
— ServerName not implemented in XE for this event
)
),
ADD EVENT sqlserver.full_text_crawl_stopped(
ACTION
(
package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
— ServerName not implemented in XE for this event
)
),
ADD EVENT sqlserver.hash_warning(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, sqlserver.database_id — DatabaseID from SQLTrace
, sqlserver.database_name — DatabaseName from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_resource_group_id — GroupID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
)
),
ADD EVENT sqlserver.missing_column_statistics(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, sqlserver.database_id — DatabaseID from SQLTrace
, sqlserver.database_name — DatabaseName from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_resource_group_id — GroupID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
)
),
ADD EVENT sqlserver.missing_join_predicate(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, sqlserver.database_id — DatabaseID from SQLTrace
, sqlserver.database_name — DatabaseName from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_resource_group_id — GroupID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
)
),
ADD EVENT sqlserver.object_altered(
ACTION
(
package0.attach_activity_id — IntegerData from SQLTrace
, sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_resource_group_id — GroupID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
— BigintData1 not implemented in XE for this event
)
),
ADD EVENT sqlserver.object_created(
ACTION
(
package0.attach_activity_id — IntegerData from SQLTrace
, sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_resource_group_id — GroupID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
— BigintData1 not implemented in XE for this event
)
),
ADD EVENT sqlserver.object_deleted(
ACTION
(
package0.attach_activity_id — IntegerData from SQLTrace
, sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_resource_group_id — GroupID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
— BigintData1 not implemented in XE for this event
)
),
ADD EVENT sqlserver.plan_guide_unsuccessful(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, sqlserver.database_id — DatabaseID from SQLTrace
, sqlserver.database_name — DatabaseName from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
— TextData not implemented in XE for this event
)
),
ADD EVENT sqlserver.server_memory_change(
ACTION
(
package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
)
),
ADD EVENT sqlserver.server_start_stop(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
)
),
ADD EVENT sqlserver.sort_warning(
ACTION
(
sqlserver.client_app_name — ApplicationName from SQLTrace
, sqlserver.client_hostname — HostName from SQLTrace
, sqlserver.client_pid — ClientProcessID from SQLTrace
, sqlserver.database_id — DatabaseID from SQLTrace
, sqlserver.database_name — DatabaseName from SQLTrace
, package0.event_sequence — EventSequence from SQLTrace
, sqlserver.is_system — IsSystem from SQLTrace
, sqlserver.nt_username — NTUserName from SQLTrace
, sqlserver.nt_username — NTDomainName from SQLTrace
, sqlserver.request_id — RequestID from SQLTrace
, sqlserver.server_instance_name — ServerName from SQLTrace
, sqlserver.server_principal_name — LoginName from SQLTrace
, sqlserver.server_principal_sid — LoginSid from SQLTrace
, sqlserver.session_id — SPID from SQLTrace
, sqlserver.session_resource_group_id — GroupID from SQLTrace
, sqlserver.session_server_principal_name — SessionLoginName from SQLTrace
, sqlserver.transaction_id — TransactionID from SQLTrace
, sqlserver.transaction_sequence — XactSequence from SQLTrace
)
)
ADD TARGET package0.event_file
(
SET filename = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log\XE_Default_Trace.xel',
max_file_size = 20,
max_rollover_files = 5
)