DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • MDC Logging With MuleSoft Runtime 4.4
  • Oracle: Migrate PDB to Another Database
  • Unveiling the Clever Way: Converting XML to Relational Data
  • Constructing Real-Time Analytics: Fundamental Components and Architectural Framework — Part 2

Trending

  • Analyzing Techniques to Provision Access via IDAM Models During Emergency and Disaster Response
  • Navigating Change Management: A Guide for Engineers
  • Memory-Optimized Tables: Implementation Strategies for SQL Server
  • AI Speaks for the World... But Whose Humanity Does It Learn From?
  1. DZone
  2. Data Engineering
  3. Databases
  4. Extended Events: Avoid the XML

Extended Events: Avoid the XML

I ditched the XML, and so can you!

By 
Grant Fritchey user avatar
Grant Fritchey
·
Apr. 11, 21 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
6.6K Views

Join the DZone community and get the full member experience.

Join For Free

One story I hear over and over goes like this: I tried setting up Extended Events, but then I saw the output was XML so I stopped.

Look, I get it. I don’t like XML either. It’s a pain to work with. It’s actively difficult to write queries against it. If there weren’t a ton of ways to avoid the XML, yeah, I would never advocate for Extended Events. However, here we are, I have ten pages of blog posts that at least mention Extended Events. Why? Because I avoid the XML (most of the time). Lots of other people do as well. You can too. Let’s see how.

Live Data Window

I have a video that goes into this in detail right here. But the core concept is simple. If you right-click on any Extended Events session inside SSMS, if it’s an actively running session, you can see a menu choice: Watch Live Data. Clicking on that opens up the Live Data window. You can see this in action in the video above.

Now, we do hit a problem here, almost as bad as the XML. Here’s the output when you first open it:

The top part of the screen are all the events. In this case, I’m capturing queries through sql_batch_completed and rpc_completed. Selecting any one event on the top of the screen will show you the details of that event in the bottom of the screen.

Admission time. I used Extended Events just like this for well over a year, and I was happy. It’s embarrassing. Why? Because that isn’t how you use this. It’s a generic viewer for any kind of event. However, it doesn’t have to stay that way. Instead, I can customize the view for my session. What’s more, that customization is saved, automatically, and will be reused.

So, how does that work? Two ways.

First, you can right-click in the details on any one of those fields. Doing so opens up this menu:

Click on Show Column in Table, and that field is added to the screen above the details.

Another way is to right-click in that top view, right on the top of the grid (maybe on the timestamp column, not that it matters, just at the top of the grid). You’ll get a menu that looks like this:

Click on the “Choose Columns…”. This opens a new window:

I’m not going into the details of how to use this. Honestly, I think it’s pretty self-explanatory. On the left you have all the data being captured by the events defined in your session. Move them to the right to create your own customized view. For example, here’s the view I use most often when looking at query performance data:

Now, suddenly, this is useful. I can see the query, either batch or statement, the duration, reads, CPU, writes, and all laid out in a nice neat format. What’s more, once you’ve done this, you can still click on any given line and see the details. However, now you get all sorts of additional functionality. You can search these columns. You can sort, group by, and aggregate. You can filter this data by time, or on any column and value. In short, you have a tool for exploring the data, completely avoiding the XML in its entirety.

Now, millions of rows, make the tool crawl. So it’s only good for slightly smaller chunks of data. However, you can watch data live, as I walked you through in this demo. Alternatively, you can open files directly. You can create a customized view of your data and then reuse that customization with no extra work at all. You can even save it and pass it to coworkers or put it on multiple machines.

You can avoid the XML.

DBATools

If you don’t already know about DBATools, well you are in for a treat. Follow this link and experience happy goodness. This is a community-driven set of PowerShell tools that will absolutely change the way you administer and work with SQL Server. And it won’t cost you a penny.

And, best of all, DBATools has had Extended Events functionality for years. And not just one or two commands. A whole slew of functionality to help you work with and support Extended Events:

While all these tools are going to help you out, we’re going to focus on one and only one: Read-DbaXEFile. I’m not going into extensive code demos here. One, it’s too easy to use. Two, DBATools goes out of their way with examples and code samples, so I’m just going to link to their documentation right here.

Now, using DBATools, you don’t have to try to figure out XPath (it’s no fun, trust me). Instead, you can query the file directly into human-readable form. What’s more, since you’re already in PowerShell, just pipe it out to any other format or location that you can imagine. Also, Powershell really isn’t bothered by millions of data points. That makes this a great resource if you have large results from Extended Events sessions.

You can avoid the XML.

Conclusion

Just using these two methods, and nothing else, you can avoid the XML. So, if your first experience was looking at XML and you’ve punted on the whole concept of Extended Events, time to come around again. Extended Events are not hard to use. They’re really simple. In fact, once you have these two tools in your pocket, Extended Events become extremely powerful and extremely easy.

I don’t normally ask this, but do me a favor, share this one with your coworkers, especially your more senior coworkers. Far too many of them are avoiding Extended Events. Some of them had a bad experience in 2008. Some of them saw, or heard about, the XML, so they punted. Others just heard people saying bad things, so they never even bothered to look. They need to get reintroduced to the topic because Extended Events are here to stay. All new functionality within SQL Server have Extended Events, no Trace Events at all. Azure SQL Database only lets you use Extended Events. There’s more functionality than in Trace, and finally, these things put less of a load on the engine. Extended Events are good.

Don’t just take my word for. Listen to all these people.

So, Extended Events really are the future. It’s time that everyone found out, the future is actually really easy and doesn’t involve XML.

XML Event Database

Published at DZone with permission of Grant Fritchey, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • MDC Logging With MuleSoft Runtime 4.4
  • Oracle: Migrate PDB to Another Database
  • Unveiling the Clever Way: Converting XML to Relational Data
  • Constructing Real-Time Analytics: Fundamental Components and Architectural Framework — Part 2

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!