I have been working on building visualizations for various kinds of analysis that I perform for my customers. One such useful visualization was the use of Power View for analyzing the data available in the SQL Server Default Trace. The query below lets you retrieve all the information in the default traces. This same query is used to populate the Power Pivot table in the Excel file.
declare @enable int -- Check to find out if Default Server Side traces are running select top 1 @enable = convert(int,value_in_use) from sys.configurations where name = 'default trace enabled' if @enable = 1 --default trace is enabled begin declare @d1 datetime; declare @diff int; declare @curr_tracefilename varchar(500); declare @base_tracefilename varchar(500); declare @indx int ; select @curr_tracefilename = path from sys.traces where is_default = 1 ; set @curr_tracefilename = reverse(@curr_tracefilename) select @indx = PATINDEX('%\%', @curr_tracefilename) set @curr_tracefilename = reverse(@curr_tracefilename) set @base_tracefilename = LEFT( @curr_tracefilename,len(@curr_tracefilename) - @indx) + '\log.trc'; select EventCat.name as Category, EventID.name as EventName, Events.* from ::fn_trace_gettable( @base_tracefilename, default ) Events inner join sys.trace_events EventID on Events.EventClass = EventID.trace_event_id inner join sys.trace_categories EventCat on EventID.category_id = EventCat.category_id end
Once I have all the trace data available in my Power Pivot table, I created calculated columns for Day, Hour and Minute. Now that I have all the data readily available for me, I went about creating the main dashboard which provides a view of all the events that occurred along with a time line view. All this took me less than 5 minutes after I had finished writing the query! Pretty quick. Now I have an interactive report that I can use for performing various kinds of analysis.
The screenshot below will show that there was only one event raised for the Server event category and the actual time of occurrence is shown in the line graph. A simple mouse over on the point will give you the exact details. Now isn’t that a simple way to track down events!
I will provide a final version of the Excel sheet once I have completed the other dashboards and sanitized the information available in the Power Pivot table.
Pingback: WOOT: Schema Changes History Report on Power View | TroubleshootingSQL
Pingback: SQLBangalore Annual Day Event | TroubleshootingSQL