Sql-server – Capture Extended Events Histogram only during time window

extended-eventsmonitoringsql server

We have a problematic time window during night on the weekends. I want to set up multiple Extended Events sessions to capture some data and get insight.

Most of them will target a file, which I can read later, but my problem is with Histogram.

I can configure a job to alter XE session to start at specific time, but I can't stop the session, because it would delete the Histogram data from memory.

AFAIK I cannot save the Histogram results from memory to disk, while it's running.

Maybe there is a way to only capture data in histogram if I set up a timestamp predicate on the actual Event (haven't tested this) and let the XE session run during the weekend and read the results on Monday.

Is there any other way how to capture the Histogram result only during a specific time window?

Best Answer

So I've solved it.

I created a table with xml column and I'll query the sys.dm_xe_session_target directly with a scheduled job right before stoping the session and save the xml result to my table (which will be persisted).