This section looks at how to
view the data captured by Extended Events sessions. Several different types of targets can be
used; and when using SQL Server Management Studio, there are different
ways to view their content.
The most likely way you’ll view captured data to
begin with is as it happens. Viewing live data from some session
targets is natively supported in SQL Server Management Studio, meaning
you can watch event data being collected as it happens — just as you
can in Profiler, for example.
However, once the session has stopped you might
want to review the data long after it was captured, or on a totally
different server or PC. SQL Server Management Studio also supports this
by opening event files for viewing, in much the same way that Word
opens a document file.
Finally, there are some targets, such as the ring
buffer, that SQL Server Management Studio doesn’t easily handle;
instead, it shows the raw XML data that it holds. To extract data from
this target, T-SQL queries are needed, although the same queries can
also be used to query event files, so you’ll be able to reuse your
queries once they are written.
- Event files
- Memory structures, such as the event counter and histogram
- XML-based ring buffer
1. Viewing Event File Data
Using an event file as your session’s
target is a good choice, as it is the best choice of target given its
flexibility when it comes to viewing the captured data in it. Using SQL
Server Management Studio, you can view their contents both in real time
as the data is being captured and as a standalone data file after the
session has stopped.
1.1 Viewing Live Data
This example uses the session created
earlier, which captures login events after ensuring it’s started. After
right-clicking on the session in SQL Server Management Studio, click
the Watch Live Data option, as shown in Figure 1.
This opens a new tab in SQL Server Management
Studio that says “Retrieving event information from server. . .” and
then you will begin seeing events as they are captured. Connecting to
the instance from another PC caused the events shown in Figure 2.
The output screen is divided into two parts,
which are identified with boxes in the screenshot. The top box displays
a list of all the events that have been captured — in this example,
several login events. The bottom box shows the event and global fields
captured for the event selected in the top box.
However, more information can be displayed in the
top box if you’d rather see more fields when events are being captured.
You can customize the view by right-clicking on the column bar at the
top of the events and selecting Choose Columns (see Figure 3). The Choose Columns dialog will then appear (see Figure 4).
This will reconfigure the live data view to look something like what is shown in Figure 5.