IT tutorials
 
Database
 

Diagnosing SQL Server 2012 Using Extended Events : Viewing Data Captured by Extended Events (part 2) - Viewing Saved Data, Viewing In-Memory Targets

12/28/2013 2:07:23 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

1.2 Viewing Saved Data

If you’ve configured your session to use an event file as its target, then the captured events will also be written to disk. You can read the event file’s content from disk while the session is still running, or after the session has been stopped, you might copy it from the server to your laptop.

To open the file, select File ? Open ? File within SQL Server Management Studio, from where you can then browse to wherever you keep your event files. By default, they are in the following path:

C:\Program Files\Microsoft SQL Server\MSSQL11.x\MSSQL\Log

and have a default file extension of .xel. Opening one of these files presents you with the same data you saw when live data was being shown.

Event files can also be queried using T-SQL. Like SQL Trace, the function sys.fn_xe_file_target_read_file reads an operating system file and returns it as XML-based table data. Writing queries to handle XML is something you’ll become good at if you want to perform a lot of analysis on Extended Events data; but for now, the following query shows an example of how you can read the event file to see the login events you captured:

select event_data.value('(event/@timestamp)[1]', 'datetime2') as 
[Event_Time_UTC],
event_data.value('(event/action[@name="nt_username"]/value)[1]',
'varchar(100)') as [NT_Username],
event_data.value('(event/action[@name="client_hostname"]/value)[1]',
'varchar(100)') as [Client_Hostname],
event_data.value('(event/action[@name="client_app_name"]/value)[1]',
'varchar(100)') as [Client_Appname]

from (select cast(event_data as xml)
from sys.fn_xe_file_target_read_file('C:\Program
Files\Microsoft SQL Server\MSSQL11.SQL2012\MSSQL\Log
Logins_0_129805987593580000.xel', null, null, null)
) as results(event_data)
order by [Event_Time_UTC]

The preceding returns the following results:

Event_Time_UTC              NT_Username       Client_Hostname   Client_Appname
--------------------------- ---------------- --------------- -------------------
2012-05-04 09:55:06.6850000 Gavin-VAIO\Gavin GAVIN-VAIO Microsoft SQL Server Management Studio
2012-05-04 09:55:06.7000000 Gavin-VAIO\Gavin GAVIN-VAIO Microsoft SQL Server Management Studio
2012-05-04 09:55:06.7100000 Gavin-VAIO\Gavin GAVIN-VAIO Microsoft SQL Server Management Studio
2012-05-04 09:55:06.7690000 Gavin-VAIO\Gavin GAVIN-VAIO Microsoft SQL Server Management Studio

The timestamp used by Extended Events is always stored in a UTC format; you may want to use the dateadd or similar functions to format the timestamp for your time zone. Whether or not you choose to do that depends on why you’re collecting the data and whether local time information is important.

1.3 Viewing In-Memory Targets

Some of the targets are the result of calculations being performed on captured data, rather than a dump of the raw data itself — for example, the event counter. The results of these targets are still available for viewing in SQL Server Management Studio, but whereas the event file target was updated in almost real time, the in-memory targets have to be manually refreshed or scheduled to be refreshed. This is not as big a problem as it sounds, as they can still be refreshed every few seconds; you just have to configure it first.

For this example, the login session from the previous section has been reconfigured and an event counter target added. You can see this in the list of targets in SQL Server Management Studio, as shown in Figure 6.

FIGURE 6

image

Once the session is running, you can right-click on the event counter target and select View Target Data. As shown in Figure 7, this will display the event counter’s data as well as a message saying “The target data will not be refreshed. Right click the table to manually refresh or set the automatic refresh interval.” Right-clicking will show that you can have it auto-refresh anywhere between every five seconds and every hour.

FIGURE 7

image

You can view the results from the histogram target in the same way that you viewed the event counter just shown; however, because these are in-memory data structures, their results aren’t written to the event file or in fact kept anywhere once the session is stopped. This is perhaps where analysis of an event file using T-SQL after testing may be more appropriate.

 
Others
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us