Figure 4. Extended Events relationships Events – events represent the execution points of the process, in this case SQL Server. Events carry relevant information themselves, and they can also be fired upon to trigger actions. Targets targets consume events and indicate where output is located, such as a file, – ring_buffer, or a bucket with aggregation. Targets can process events synchronously or asynchronously. Actions actions are performed synchronously in association with bound events. They – can be used to accomplish certain tasks or simply provide more information relevant to the events. determine the type of the package objects. They are based on the length –types and pattern of collected data. Predicates predicates are logical rules used to filter captured events. They help – reduce the volume of captured data and tailor down the output for analysis. Maps maps are tables that map internal object values to user-friendly descriptions. – For more information about these objects, see in SQL Server 2008 Books Online. Create an Extended Events Session Using Extended Events packages, you can create sessions to host the Extended Events engine and perform actions against various targets. For example, the following code creates a session that traces event of database log auto growth. -- make sure the C:\xevent folder exists create event session log_growth on server ADD EVENT sqlserver.databases_log_growth (action (sqlserver.database_id)) add target package0.asynchronous_file_target (SET filename=N'C:\xevent\log_growth.xel', metadatafile=N'C:\xevent\log_growth.xem');
Figure 4. Extended Events relationships Events – events represent the execution points of the process, in this case SQL Server. Events carry relevant information themselves, and they can also be fired upon to trigger actions. Targets – targets consume events and indicate where output is located, such as a file, ring_buffer, or a bucket with aggregation. Targets can process events synchronously or asynchronously. Actions – actions are performed synchronously in association with bound events. They can be used to accomplish certain tasks or simply provide more information relevant to the events. –types determine the type of the package objects. They are based on the length and pattern of collected data. Predicates – predicates are logical rules used to filter captured events. They help reduce the volume of captured data and tailor down the output for analysis. Maps – maps are tables that map internal object values to user-friendly descriptions. For more information about these objects, see in SQL Server 2008 Books Online. Create an Extended Events Session Using Extended Events packages, you can create sessions to host the Extended Events engine and perform actions against various targets. For example, the following code creates a session that traces event of database log auto growth. -- make sure the C:\xevent folder exists create event session log_growth on server ADD EVENT sqlserver.databases_log_growth (action (sqlserver.database_id)) add target package0.asynchronous_file_target (SET filename=N'C:\xevent\log_growth.xel', metadatafile=N'C:\xevent\log_growth.xem');