One of the open secrets of Windows Azure is that diagnostics is powerful but also very tedious and partly error-prone. In addition, there is no really good and useful tooling provided by Microsoft. We want to have a light-weight means to monitor application, look at performance counters, see event logs etc.
There is the SCOM MP for Windows Azure, but this is more an enterprise-targeted solution which cannot really be called light-weight. This leaves us with 3rd party tools.
My 3rd party tool of choice for doing diagnostics and monitoring of Windows Azure applications is Cerebrata’s Azure Diagnostics Manager (ADM).
But before we use any tools to visualize data we need to set up and instruct our code to collect diagnostics data. In the following example we set up three performance counters and two event logs to be collected and be transferred over to the configured storage account:
public class WebRole : RoleEntryPoint { public override bool OnStart() { var diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration(); var procTimeConfig = new PerformanceCounterConfiguration(); procTimeConfig.CounterSpecifier = @"\Processor(*)\% Processor Time"; procTimeConfig.SampleRate = System.TimeSpan.FromSeconds(5.0); diagConfig.PerformanceCounters.DataSources.Add(procTimeConfig); var diskBytesConfig = new PerformanceCounterConfiguration(); diskBytesConfig.CounterSpecifier = @"\LogicalDisk(*)\Disk Bytes/sec"; diskBytesConfig.SampleRate = System.TimeSpan.FromSeconds(5.0); diagConfig.PerformanceCounters.DataSources.Add(diskBytesConfig); var workingSetConfig = new PerformanceCounterConfiguration(); workingSetConfig.CounterSpecifier = @"\Process(" + System.Diagnostics.Process.GetCurrentProcess().ProcessName + @")\Working Set"; workingSetConfig.SampleRate = System.TimeSpan.FromSeconds(5.0); diagConfig.PerformanceCounters.DataSources.Add(workingSetConfig); diagConfig.PerformanceCounters.ScheduledTransferPeriod =
TimeSpan.FromSeconds(30); diagConfig.WindowsEventLog.DataSources.Add("System!*"); diagConfig.WindowsEventLog.DataSources.Add("Application!*"); diagConfig.WindowsEventLog.ScheduledTransferPeriod =
TimeSpan.FromSeconds(30); DiagnosticMonitor.Start(
"Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString",
diagConfig); return base.OnStart(); } }
When you look at your storage account after a while you see that for the above example two tables have been created (if they haven’t been already in place), namely WADPerformanceCountersTable and WADWindowsEventLogsTable:
Of course you can use your storage explorer of choice and look at the raw data collected Or we choose the above mentioned ADM to use its Dashboard feature to visualize our performance counter and event logs (note that ADM polls the data from the storage account and you can specify the poll interval):
If we like we can even drill into each of the diagnostics categories. The following picture shows a detailed view of three performance counters:
Again: the Azure Diagnostics Manager is a handy tool and is what I personally have been using in projects and recommending our clients.
Hope this helps.