Alert RSS Feed for Azure Applications Leveraging Windows Azure Diagnostics

Slalom Consultant Joel Forman

Slalom Consultant Joel Forman specializes in cloud computing and the Windows Azure Platform.

One important aspect to building scalable applications in the cloud is the ability to debug, troubleshoot, and monitor deployed services.  In this post I will demonstrate how to add a simple RSS Feed for alerts to your cloud service that leverages the information being collected via Windows Azure Diagnostics.

Windows Azure Diagnostics (WAD) provides the ability to configure your services running in Windows Azure to collect diagnostic information and persist this information to a Windows Azure storage account for your consumption and analysis.  For example, through WAD I can view trace logs, performance counters, event logs, and even IIS logs for all of the instances running within my hosted service.  Centralizing and persisting this information is a valuable service, especially considering that cloud services that scale can have a large number of instances.  There are many tools for consuming this diagnostic data.  My favorite is Cerebrata’s Azure Diagnostics Manager, which provides a dashboard and advanced querying capabilities.

WAD does a nice job of handing the collecting of diagnostics data.  But it doesn’t provide monitoring or alerting capabilities to date.  One simple way to generate some basic alerting capabilities is to add an RSS Feed to your Web Role that queries data collected by WAD and surfaces key information that you would want to know about.  Here are some quick steps to create such a feed that will include any log message from any instance (web, worker, etc.) with the category of “Error” or “Critical”.

For this example, I started with a new cloud solution consisting of one ASP.NET MVC Web Role.

Make sure Windows Azure Diagnostics is enabled in the properties of your Web Role.  Note that a configuration setting is added to your ServiceConfiguration.cscfg file designating the storage account where the diagnostics data is persisted.  In this example, I am running locally so I am using development storage.

I modified the settings for WAD via the OnStart event for my Web Role to persist logs more frequently for this demo.  I just recently read this post by Cory Fowler that shows how to do this via a configuration file as well.

I added a try/catch block that catches an exception and I am tracing that exception using Trace.TraceError.  By default for my web role in my web.config, WAD has already been configured as a trace listener for me.  This will show up in my diagnostics storage account, within a Table Storage table called WADLogsTable that gets generated by WAD.

Time to implement the feed.  I did a quick search and found this solution for returning an RSS Feed from a Controller Action.  (Thanks!)

I created a couple of classes to represent my TableServiceContext and TableServiceEntity that we will use in querying Windows Azure Table Storage via the Storage Client Library included in the Windows Azure SDK.

Finally, I added a new Controller and Action for my alert feed.   Via LINQ I am able to query the logs table to retrieve the most recent messages with the level of “Error” or worse.  Leveraging the Syndication classes included in the .NET framework, we can easily enumerate the log messages and return a feed.

I can subscribe to this feed from a feed reader on my mobile device, and/or add this feed to my Outlook inbox.

There are a lot of more advanced ways to accomplish monitoring and alerting via Windows Azure.  This is just a simple solution to gain some real-time visibility into important events, without much overhead to implement.

You can download the source code for the Alert Feed Controller here.

Slalom Consulting's Seattle Office Slalom Consulting Cloud
More about Slalom Consulting’s Seattle office. More about Slalom Consulting’s Cloud focus.

subscribe by emailSubscribe to be emailed about new Cloud posts.

About Joel Forman
Joel Forman is a Solution Architect at Slalom Consulting and specializes in cloud computing and the Windows Azure Platform.

One Response to Alert RSS Feed for Azure Applications Leveraging Windows Azure Diagnostics

  1. Pingback: Windows Azure and Cloud Computing Posts for 7/29/2011+ - Windows Azure Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: