I still remember the good old
days where we had a huge instrumentation database wherein developers would log
all the data – URLs, user navigation path, query parameters, exceptions,
browser information, region information, etc to help in debugging the issues
and generating required reports. Application Insights offers all these
capabilities and much more with simple configuration and ready to use detailed
reports.
This post is divided into two
parts –
a. Installation
& configuration
b. Usage
of the reports
Installation & configuration –
Prerequisites
·
Visual Studio 2013 or later version(s)
·
Subscription to Microsoft Azure
Visual Studio
Application Insights has Free, Standard & Premium pricing tiers.
1. Login
to Azure portal and create a new Application Insight resource by selecting ASP.Net Web
Application
2. Make
a note of the Instrumentation key
Note: Intentionally
erased the details
These first two steps creates a
resource and now it is ready for any application to be configured for
monitoring.
3.
Install the SDK
a.
Right click on your Project and install
ApplicationInsights NuGet package
b.
Search for Microsoft.ApplicationInsights.Web and
install
Note: If “Application Insights for
Visual Studio” extension is installed, then on right click of the project you
will see an option “Add Application Insights” which is another way of
configuring Application Insights.
c.
ApplicationInsights.config file will be added by
the NuGet installation. Edit this file and add the below tag just before the
file end.
<InstrumentationKey>Your
instrumentation key here</InstrumentationKey>
|
Note: This above configuration in the
ApplicationInsights.config will write the logistics from all the available
environments. If the requirement is to configure different Application Insights
for each environment then the best solution is to configure the Instrumentation
Key in Cloud.config and write the below statement in Global.asax.cs to fetch
the key based on environment.
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey
= CloudConfigurationManager.GetSetting("InstrumentKeyName");
|
At this point we are done with
the installation & configuration. Running the project (debug mode/release
mode/published code) will start writing the logs.
Usage of the reports –
1. Login
to Azure portal and browse to Applications Insight.
2.
Click through the applications and then through
the available reports to see more details.
Various reports are already created based
on the ApplicationInsights data log –
·
Failures
This reports all the failures with exception details
happened in last 24 hours along with giving additional details about the % of
each exception against the total number of exceptions logged.
One great thing about this report –
It digs down from the URL to method name to operating
system to even browser version for a generated exception. This is like a whole
universe of data points for debugging the issue. This detailed information has
helped our team more than once to find the root cause sooner.
·
Performance
Gives performance number against each URL which will
help in determining the low performance pages.
·
Browser
Gives the details about the browser & their
versions used to access the application.
This post will
not get into the details of each of the report. I request the readers to
explore other reports & options.
Add
Client side monitoring (Web browsers)
The SDK installed from NuGet
sends the monitoring data from server side code. To add monitoring on client
side for web browsers,
a.
Download the Javascript snippet from Azure
portal and put it in every page or the Master Page.
The code snippet
will have the Instrumentation Key.
Please leave your
feedback and queries in the comments section. Thank you!