Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 5932

Alerting on ASP.NET Exceptions thru the Windows Azure Management Pack

$
0
0

One of the most useful health-related services offered by ASP.NET is the Web Events feature. By modifying the Web.config file, you can use the health monitoring system to log unhandled exceptions, expired forms, authentication tickets, and any other data you want logged in your application. If you want to get more information about this, you can read this KB article http://support.microsoft.com/kb/893664.

This said, in Windows Azure Cloud Services (PaaS), some of this is pre-configured for you, and all unhandled errors and audit failures are written to the Windows Event Log within the Application folder as shown:

ASP.NET Exception in Application event log

For WAD (Windows Azure Diagnostics) to capture the health event you can either configure WAD to read from the event log. If you are monitoring Azure with the Azure management pack (either the old one, or the new preview one which was released last week and that I showed at MMS 2013) you are probably already doing this.

So, if those exceptions are in the event log, we can pull them thru management packs rules to our Operations Manager management group, and alert on them, right? Right. Piece of cake. Here I have written an example rule that does just that (XML for the MP attached below):

ASP.NET Exception Alert from Azure

 

Here’s the XML of the MP I wrote for this – this is referencing the new Azure Fabric Management Pack PREVIEW that was released last week:

 


< ManagementPack SchemaVersion="2.0" ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
   
      Azure.AddOn
      1.0.0.20
   

    Azure.AddOn
   
     
        Microsoft.SystemCenter.WindowsAzure
        1.0.0.0
        < PublicKeyToken>31bf3856ad364e35
     

     
        System.Health.Library
        7.0.8427.0
        < PublicKeyToken>31bf3856ad364e35
     

     
        System.Library
        7.5.8501.0
        < PublicKeyToken>31bf3856ad364e35
     

   

 

 
    
     
        Alert
        < DataSources>
          < DataSource ID="DS" TypeID="AzureMP!Microsoft.SystemCenter.WindowsAzure.RoleInstance.EventLog.CollectData.DS">
            < IntervalSeconds>300
            < TimeoutSeconds>60
         
       
        < ConditionDetection ID="CD" TypeID="System!System.ExpressionFilter">
         
           
             
                < SimpleExpression>
                  < ValueExpression>
                    < XPathQuery>EventNumber
                 
                  Equal
                  < ValueExpression>
                    1309
                 
               
             

             
               
                 
                    < SimpleExpression>
                      < ValueExpression>
                        < XPathQuery>PublisherName
                     
                      Equal
                      < ValueExpression>
                        ASP.NET 2.0.50727.0
                     
                   
                 

                 
                    < SimpleExpression>
                      < ValueExpression>
                        < XPathQuery>PublisherName
                     
                      Equal
                      < ValueExpression>
                        ASP.NET 4.0.30319.0
                     
                   
                 

               

             

           

         

       
        < WriteActions>
          < WriteAction ID="GenerateAlert" TypeID="Health!System.Health.GenerateAlert">
            1
            1
            < AlertName />
            < AlertDescription />
            < AlertMessageId>$MPElement[Name='Azure.AddOn.ASP.NET.Exception.AlertRule_AlertMessage']$
            < AlertParameters>
              $Data/EventDescription$
           
           
              < SuppressionValue />
           

         
       
     

   
 

 
    < StringResources>
      < StringResource ID="Azure.AddOn.ASP.NET.Exception.AlertRule_AlertMessage" />
   
 

  < LanguagePacks>
    < LanguagePack ID="ENU" IsDefault="false">
      < DisplayStrings>
        < DisplayString ElementID="Azure.AddOn">
          Azure MP AddOn for ASP.NET
          Azure MP AddOn for ASP.NET
       
        < DisplayString ElementID="Azure.AddOn.ASP.NET.Exception.AlertRule">
          ASP.NET Exception
          ASP.NET Exception
       
        < DisplayString ElementID="Azure.AddOn.ASP.NET.Exception.AlertRule_AlertMessage">
          ASP.NET Exception
          Event Description: {0}
       
     
      < KnowledgeArticles>
   
 
< /ManagementPack>

 

 

Granted, it is not full-blown APM functionality, and you can’t convert to IntelliTrace format, but once you have those exceptions, you can route them to developers thru the TFS Connector like you would do for APM Exceptions:

Assign to Engineering 

 

Please also note that it is not easy to do “proper” alert suppression based on the exception message or call stack, because the “EventDescription” of those ASP.NET events contains timestamps which make the description unique every single time. Also, with the Azure event DataSource, since it reads events from WAD, and parameters are lost. Hence I defaulted to do suppression based on the rule itself (this will hide multiple different exceptions that might be happening on the same role instance).

Even with these limitations, I hope it is helpful to see how you can extend the Azure MP (that focuses on the “fabric” layer by default) to also look at your application’s health!

Happy Azure monitoring!


Viewing all articles
Browse latest Browse all 5932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>