About 3 months ago as some colleagues and I were working on the "Advanced Debugging Hands On Lab for Windows Azure" (for more info contact me via this blog) we identified an interesting opportunity within the Azure MMC. If you've worked with this tool you may have seen that the default export option for the performance counters log is an Excel file. More specifically a CSV file. This is fine for getting a dump of event log data or native Azure infrastrucutre logs but for performance counter data this is not ideal.
The format of the data exported in the Azure MMC made it impossible to use our existing Performance Monitor tool on Windows (perfmon) or our Performance Analysis of Logs tool from codeplex. These tools are essential for us in support as we do initial problem analysis. Issues like managed or unmanaged memory leaks, high and low CPU hangs, and process restarts are just a few examples of issues that start with perfmon analysis. These issues do not go away in the cloud!
The Azure MMC team made an outstanding design decision that allowed us to very quickly build a plug-in that could provide additional options for exporting those performance counters however we want. Because the team decided to take advantage of the Managed Extensibility Framework (aka MEF) it was easy to extend the capabilies of the MMC with our own functionality. Here are the steps that were required to code up the solution:
- Start from a new WPF User Control Library project.
- Next you'll want to set your project to target .NET Framework 3.5 if you are using Visual Studio 2010 because the version of MEF that the Azure MMC uses is pre .NET 4.0
- Add References to the following assemblies located in your %InstallRoot%\WindowsAzureMMC\release folder
- Next, the implementation decision made in the Azure MMC base classes meant we had to follow the MVVM pattern for WPF to create a ViewModel that would bind to the controls rendered as part of the dialog when the "Show" button is clicked. This ViewModel class must inherit from ViewerViewModelBase<T> which is found in the WindowsAzureMmc.ServiceManagement dll referenced above. T in this case will be your actual view with all of the XAML markup.
- The next part was easy, to get the perfmon counter data we just needed to override the OnSearchAsync and OnSearchAsyncCompleted methods from the ViewerViewModelBase type which takes care of making the calls to the Azure APIs and retrieving the data.
- Now for the fun part, we still had to get the data in the proper structure to be readable by perfmon and PAL. To do this we wrote an Export command (see Code Snippet 1) that would be triggered from the pop up in the same way it is triggered to export to excel. The only difference is in this case we take all the incoming performance counter data and group it first by tickcount and then map that back to the unique columns which are created as "RoleName\RoleInstance\CounterID" (see Code Snippet 2).
- Now that we had all the data restructured we needed to come up with a way to to take the new CSV output and get it into the native BLG perfmon format. Big thanks to my colleague Greg Varveris for the design approach here. All we needed to do was use a Process.Start command to run a conversion of the CSV file to BLG using relog.exe and then launch the resulting file with perfmon directly!
Once this DLL is built and dropped into the WindowsAzureMMC\release folder it is automatically picked up by the MMC and you will see a new option in the "Performance Counters Logs" drop down (note: if you drop the DLL in the release folder when the Azure MMC is already running you need to do a "refresh plugins" to get the new option to show up)
Now when you click on "Show" there will be a new dialog that opens and allows you to open the data directly in perfmon.
Here's a quick snapshot of the perfmon data. Notice it shows multiple roles, multiple instances, and multiple counters. There is no limitation to the amount of data you want to pull down from the MMC and show in perfmon!
On top of getting to open the data directly in perfmon you also will find that the data is being saved on disk for you to collect and store for later viewing or feed into a tool like PAL to determine if you have any bad resource usage trends. All you need to do is go to your C:\Users\%username%\AppData\Local\Temp and you will see the files there.
We'd love to get feedback on this plug in and whether or not it was useful to you for reviewing your Azure application performance data. You can download it here: Windows Azure MMC Downloads Page