

-- A. THIS METADATA LIST ALL DEFINED (NOT NECESSARILY ACTIVE) ITEMS

--  Lists all event session definitions.  
select * from sys.server_event_sessions 

--  Returns a row for each action on each event of an event session. 
select * from sys.server_event_session_actions 
 
--  Returns a row for each event in an event session.
select * from sys.server_event_session_events 
 
--  Returns a row for each customizable column that was explicitly set on events and targets.
select * from sys.server_event_session_fields 
 
--  Returns a row for each event target for an event session.
select * from sys.server_event_session_targets 

--  Returns information about session dispatcher pools.
select * from sys.dm_os_dispatcher_pools 

-- B. THIS IS METADATA ABOUT ACTIVE EVENT SESSIONS
 
--  Returns information about an active extended events session.
select * from sys.dm_xe_sessions 

--  Returns information about session targets. 
select * from sys.dm_xe_session_targets 

--  Returns information about session events. 
select * from sys.dm_xe_session_events 

--  Returns information about event session actions.
select * from sys.dm_xe_session_event_actions 
 
--  Provides a mapping of internal numeric keys to human-readable text.
select * from sys.dm_xe_map_values 

--  Shows the configuration values for objects that are bound to a session. 
select * from sys.dm_xe_session_object_columns 
 
-- C. THIS IS METADATA ABOUT EXISTING PACKAGE ITEMS, NOT ACTIVE EVENT SESSIONS

--  Returns a row for each object that is exposed by an event package 
select * from sys.dm_xe_objects 
where object_type = 'action'
order by package_guid

-- all the objects that can be used in comparisons
select * from sys.dm_xe_objects 
where object_type like 'pred_source%'
order by package_guid, object_type, name

-- all the comparisons
select * from sys.dm_xe_objects 
where object_type like 'pred_c%'
order by package_guid, object_type, name

select * from sys.dm_xe_objects
where object_type = 'map'

select map_value
     , map_key
from sys.dm_xe_map_values
where name = 'keyword_map'

select name, column_id, object_name, description from sys.dm_xe_object_columns
--where column_type = 'customizable'
where object_name = 'synchronous_bucketizer'
 
--  Returns the schema information for all the objects.
select * from sys.dm_xe_object_columns 

select convert(varchar(55),o.name) as [Object Name]
      ,convert(varchar(25),c.name) as [Column Name]
      ,c.column_id
      ,convert(varchar(12),c.column_type) as [Col_Type]
     -- ,convert(varchar(35),o.description) as [Obj Desc]
     -- ,convert(varchar(25),c.description) [Col Desc]
     -- ,*
from sys.dm_xe_objects o
join sys.dm_xe_object_columns c
on o.name = c.object_name
where o.object_type = 'event' and column_type != 'readonly'
order by [Object Name]

--  Lists all the packages registered with the extended events engine.
select * from sys.dm_xe_packages 

