{"id":775,"date":"2007-08-20T21:04:00","date_gmt":"2007-08-20T21:04:00","guid":{"rendered":"\/blogs\/bobb\/post\/More-about-XEvent-actions-and-targets-(still-raining-still-dreaming).aspx"},"modified":"2007-08-20T21:04:00","modified_gmt":"2007-08-20T21:04:00","slug":"more-about-xevent-actions-and-targets-still-raining-still-dreaming","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/","title":{"rendered":"More about XEvent: actions and targets (still raining, still dreaming)"},"content":{"rendered":"<p>\nIt&#39;s another rainy day in Portland in summer, so I thought I&#39;d stay inside and write more about SQL Server 2008 Extended Events.\n<\/p>\n<p>\nI wanted to finish things off by talking about <strong>actions<\/strong> and predicates. Need to&nbsp;make a detour at <strong>targets<\/strong>, too.&nbsp;I noticed the BOL examples (my point is to try not to repeat things you can find in the BOL) don&#39;t contain an example of actions in DDL. So we&#39;ll start with them. An action is an additional piece of data that you can tack on to an event. Like a stack trace, or even a causality ID. Or sql_text.\n<\/p>\n<p>\nThe available actions can be seen with:<br \/>\nSELECT * FROM sys.dm_xe_events WHERE type = &#39;action&#39;\n<\/p>\n<p>\nSo let&#39;s try sql_text with our existing EVENT SESSION.\n<\/p>\n<p>\nCREATE EVENT SESSION PubsLocksETW<br \/>\nON SERVER<br \/>\nADD EVENT sqlserver.lock_acquired <br \/>\n&nbsp;&nbsp; (ACTION (sqlserver.sql_text) <br \/>\n&nbsp;&nbsp;&nbsp; WHERE sqlserver.database_id = 12) &#8212; (pubs database), add a predicate too<br \/>\nADD TARGET package0.etw_classic_sync_target <br \/>\n&nbsp;&nbsp; (SET default_etw_session_logfile_path = N&#39;C:\\temp\\sqletw.etl&#39; )<br \/>\nGO\n<\/p>\n<p>\nBut the sql_text doesn&#39;t appear in the ETW file. I did this a few times, because I thought I got it wrong. Maybe it will appear in the async file target, which isn&#39;t in this CTP. The BOL also says that not every action is valid for every event. Hmmm&#8230; the metadata (sys tables) seemed to be happy, but it ain&#39;t there. But I can use it with the bucketizer and pairer targets.\n<\/p>\n<p>\nThe bucketizer makes &#8230;er&#39; buckets (groups) of different &quot;readings&quot; (events)&nbsp;on a single data object. As in, group by lock type or group by cpu time. You can control how many buckets it makes. In fact that bucketizer target&nbsp;needs syntax like the following (from BOL).\n<\/p>\n<p>\nCREATE EVENT SESSION MostLocks<br \/>\nON SERVER<br \/>\nADD EVENT sqlserver.lock_acquired (where sqlserver.database_id = 12) &#8212; (pubs) <br \/>\n&#8212; this means &quot;create buckets based on object_id (object being locked in this case)&quot;<br \/>\nADD TARGET package0.synchronous_bucketizer <br \/>\n&nbsp;&nbsp;&nbsp; (SET filtering_event_name=&#39;sqlserver.lock_acquired&#39;, source_type=0, source=&#39;object_id&#39;)<br \/>\nGO\n<\/p>\n<p>\nBut how did they figure out what to put after &quot;SET&quot;? Where does &#39;filtering_event_name&#39; come from?\n<\/p>\n<p>\nSELECT * FROM sys.dm_xe_object_columns<br \/>\nWHERE column_type = &#39;customizable&#39;<br \/>\nWHERE object_name = &#39;synchronous_bucketizer&#39;\n<\/p>\n<p>\nThere they are&#8230; and the description field suggests a use for &#39;action&#39;.\n<\/p>\n<p>\nCREATE EVENT SESSION PubsLockByText<br \/>\nON SERVER<br \/>\nADD EVENT sqlserver.lock_acquired <br \/>\n&nbsp;&nbsp; (ACTION (sqlserver.sql_text) <br \/>\n&nbsp;&nbsp;&nbsp; WHERE sqlserver.database_id = 12) &#8212; (pubs database)\n<\/p>\n<p>\n&#8212; source_type= 1 means buckets by action, not by event<br \/>\nADD TARGET package0.synchronous_bucketizer <br \/>\n&nbsp;&nbsp; ( set filtering_event_name=&#39;sqlserver.lock_acquired&#39;, source_type=1, source=&#39;sqlserver.sql_text&#39;)<br \/>\nGO\n<\/p>\n<p>\nAha&#8230; now I have buckets created based on the text of the SQL statement that caused the lock, rather than by object_id.\n<\/p>\n<p>\nThis is getting to be too much for a single blog entry. But one last thing for now. You may not have noticed that I switched from using the &quot;package.asynchronous_bucketizer&quot; as the BOL does to using &quot;package0.synchronous_bucketizer&quot;. Why? Because I want to do a simple, controlled experiment and I may not want to wait for the buffer to be full and async bucketizer to write out. BTW, for a simple controlled experiment, you can do:\n<\/p>\n<p>\nUSE pubs<br \/>\nGO\n<\/p>\n<p>\nSET TRANSACTION ISOLATION LEVEL SERIALIZABLE<br \/>\nBEGIN TRAN<br \/>\nUPDATE authors SET au_fname = &#39;bob&#39;;<br \/>\nROLLBACK&nbsp; &#8212; You don&#39;t really want everyone named &#39;bob&#39;, do you?\n<\/p>\n<p>\nLeave the EVENT SESSION running to see the buckets. BOL has a cool query against the XML structure but to see the raw XML, if this is your only EVENT SESSION running&#8230;\n<\/p>\n<p>\nSELECT CAST(target_data as xml) FROM sys.dm_xe_session_targets;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#39;s another rainy day in Portland in summer, so I thought I&#39;d stay inside and write more about SQL Server 2008 Extended Events. I wanted to finish things off by talking about actions and predicates. Need to&nbsp;make a detour at targets, too.&nbsp;I noticed the BOL examples (my point is to try not to repeat things [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,29],"tags":[],"class_list":["post-775","post","type-post","status-publish","format-standard","hentry","category-extended-events","category-sql-server-2008"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>More about XEvent: actions and targets (still raining, still dreaming) - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"More about XEvent: actions and targets (still raining, still dreaming) - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"It&#039;s another rainy day in Portland in summer, so I thought I&#039;d stay inside and write more about SQL Server 2008 Extended Events. I wanted to finish things off by talking about actions and predicates. Need to&nbsp;make a detour at targets, too.&nbsp;I noticed the BOL examples (my point is to try not to repeat things [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2007-08-20T21:04:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/\",\"name\":\"More about XEvent: actions and targets (still raining, still dreaming) - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2007-08-20T21:04:00+00:00\",\"dateModified\":\"2007-08-20T21:04:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Extended Events\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/extended-events\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"More about XEvent: actions and targets (still raining, still dreaming)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"More about XEvent: actions and targets (still raining, still dreaming) - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/","og_locale":"en_US","og_type":"article","og_title":"More about XEvent: actions and targets (still raining, still dreaming) - Bob Beauchemin","og_description":"It&#39;s another rainy day in Portland in summer, so I thought I&#39;d stay inside and write more about SQL Server 2008 Extended Events. I wanted to finish things off by talking about actions and predicates. Need to&nbsp;make a detour at targets, too.&nbsp;I noticed the BOL examples (my point is to try not to repeat things [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/","og_site_name":"Bob Beauchemin","article_published_time":"2007-08-20T21:04:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/","name":"More about XEvent: actions and targets (still raining, still dreaming) - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2007-08-20T21:04:00+00:00","dateModified":"2007-08-20T21:04:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/more-about-xevent-actions-and-targets-still-raining-still-dreaming\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"Extended Events","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/extended-events\/"},{"@type":"ListItem","position":3,"name":"More about XEvent: actions and targets (still raining, still dreaming)"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=775"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/775\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}