HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Finding when a currently running Extended Events session started?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
startedeventsextendedfindingrunningsessionwhencurrently

Problem

For old-school traces, I can look in sys.traces or the SQL Server log to find when a trace was started. Is there something similar for Extended Events? I came across this blog entry about using a DDL trigger but I'm wondering if there is something better.

SQL Server 2012-2014

Solution

There is but it does not necessarily provide a "status" itself. If you look at the definition of sys.dm_xe_sessions in Books Online here:


Returns information about an active extended events session. This
session is a collection of events, actions, and targets.

The key is active extended events sessions, this DMV is only going to return those XE sessions that are running. So you basically just look at the create_time and that is when the session was started. You can verify this by looking at the system_health session as the time returned should match up to when the instance was last started.

An example is my SQL Server 2012 instance on my local machine is kept stopped most of the time until I need it. I just started it so you can see the times are pretty close:

Context

StackExchange Database Administrators Q#108988, answer score: 7

Revisions (0)

No revisions yet.