Azure Diagnostics and ASP.NET Health Monitoring

By default Windows Azure Diagnostics (WAD) does not receive ASP.NET Health Monitoring events.  The machine web.config file at %windir%\Microsoft.NET\Framework64\v4.0.30319\Config\web.config shows the default behavior of ASP.NET Health Monitoring.  Basically all unhandled errors and audit failures are written to the Windows Event Log within the Application folder as shown:

image

For WAD to capture the health event you can either configure WAD to read from the event log or you can change the behavior of where the health events are routed.  With the event log approach you’ll want to limit what WAD reads, see https://blog.smarx.com/posts/capturing-filtered-windows-events-with-windows-azure-diagnostics, using:

 Application!*[System/Provider/@Name='ASP.NET 4.0.30319.0']

I’d rather use "Application!*[System/Provider/@Name[starts-with(.,'ASP.NET')]" but was unable to get the starts-with syntax to work.  I’ve also noticed that events sent to DiagnosticMonitorTraceListener appear in table storage before those sent to the event log even with identical transfer periods configured.  Perhaps it takes one transfer period to read from the event log and another to transfer the data?

The other approach, which I prefer, is to change the web.config so that health events are routed to the DiagnosticMonitorTraceListener as shown:

      <healthMonitoring enabled="true"> 
        <providers> 
          <add name="TraceWebProvider" type="System.Web.Management.TraceWebEventProvider" /> 
        </providers> 
        <rules> 
          <remove name="All Errors Default" /> 
          <add name="All Errors Default" eventName="All Errors" provider="TraceWebProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom="" /> 
          <add name="Application Events" eventName="Application Lifetime Events" provider="TraceWebProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom="" /> 
        </rules> 
      </healthMonitoring>
  

 

Basically this tweaks the default behavior defined in the machine’s web.config instead of completely replacing it.  See the eventMappings in %windir%\Microsoft.NET\Framework64\v4.0.30319\Config\web.config to get an idea of what is possible.

When you use the event log approach your events end up in the WADWindowsEventLogsTable in Azure Storage.  Modifying web.config to route health events through DiagnosticMonitorTraceListener writes the events to WADLogsTable.

Other posts in my WAD series are available at:

https://blogs.msdn.com/b/davidhardin/archive/tags/wad/

Comments

  • Anonymous
    April 17, 2011
    its a really nice post. i will share it to all my friends . thanks