No doubt the Azure platform will eventually give us a means to monitor applications in real-time, but in the meantime this provides one way to do it here and now. I'd attempted this in the past and quickly found I couldn't access process information and performance counters due to the partial trust environment Azure-hosted applications run in. That's all changed with the March 2009 Windows Azure CTP that was released last week at MIX09, which allows applications to run in full trust if they want to.
Azure Application Monitor has 2 parts, a library and a monitoring application. You use the library to instrument your app to capture process information to cloud storage. You use the monitoring application to view that information.
Instrumenting your apps is very easy. Add a reference to the AzureMonitorLib assembly and call the AzureMonitor.Start static method in your initialization code, providing an application name and a role name. That will cause a background thread to run, periodically capturing process information and writing it to cloud storage. Here's an example of instrumenting a web role:
using Neudesic.Azure;
...
protected void Page_PreRender(object sender, EventArgs e)
{
AzureMonitor.Start("Thumbnails", "WebRole");
...
}
The monitoring app, AzureMonitor, is a WPF desktop application that reads cloud storage and displays the metrics. It refreshes the display every 15 seconds. What information is being tracked for a role?
- Application Name (you supply this in your code)
- Role Name (you supply this in your code)
- Machine Name
- Process ID
- Thread count
- Handle count
- Total processor time
- User processor time
- Private memory size
- Non-paged memory size
- Paged memory size
- Paged system memory size
- Peak paged memory size
- Peak virtual memory size
- Peak working set
- Page file usage
- Peak page file usage
- Non-paged Pool Usage
- Local machine time
- Process local start time
I was tempted to go on from here to capture all the performance counters on the machine as well. However, that ends up being a lot of information which could adversely affect the performance of your application so I decided to stick with process information for the time being. if you want to capture additional information it's easy to add new properties to the code.
1 comment:
do you really want that in page_prerender? does that mean it will get started on every request?
Post a Comment