Skip to content

TSQL scripts that shred an Extended Events session event file target into a tabular result set.

License

Notifications You must be signed in to change notification settings

BeginTry/XEvent-Shredder

Repository files navigation

XEvent-Shredder

TSQL scripts that shred an Extended Events session event file target into a tabular result set.

The output of sys.fn_xe_file_target_read_file is not particularly easy to read and interpret. Shredding the XML of the event_data column is necessary. But that is a tedious exercise. These scripts attempt to make it easy by dynamically generating a query that returns data for all selected Global Fields (Actions) and all Event Fields for each event in the session.

Blog Post/Further Reading: Shredding XML Data From Extended Events

Dave Mason - SQL Server - Extended Events

UPDATE

I've added script Read XEvent Session Event File Target ~ By Event.sql. Although there are some similarities to Read XEvent Session Event File Target.sql, note the following differences:
  1. Instead of one (potentially) giant query that covers every event in the session, there is one query per session event. The individual queries only include columns for Global Fields (Actions) and Event Fields selected for the specific event. Fewer columns make the result sets easier to interpret. With fewer calls to the XML.value() function, they are faster too.
  2. Column name aliases include the FieldType ("Global Field" or "Event Field").
  3. There is a common table expresion XE_TSQL_TypeXref, which replaces the VIEW. I thought this made more sense. But if the VIEW is preferred, it's easy enough to use that instead.

The old script tried to put every Event Field into the same query. One problem with this is that Event Field names sometimes overlap with Global Field (Action) names. ("Database Id" is a good example.) Further, when multiple events are defined for a single session, Event Field names from different events can overlap each other. This often resulted in a query with multiple columns using the same alias. All of these issues go away when using a separate query for each session event, along with aliases that include the FieldType.

About

TSQL scripts that shred an Extended Events session event file target into a tabular result set.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages