Application Insights Deep Dive Part 1 - Getting Started
Application Insights Deep Dive Part 2 - Building A Demo Server
Application Insights Deep Dive Part 3 - Deploying A Demo Web Application
Application Insights Deep Dive Part 4 - Monitoring Availability
Application Insights Deep Dive Part 5 - Monitoring Performance & Using Diagnostics
In the last post I explained how you can monitor the performance of your applications from the cloud and walked through how to troubleshoot some of the issues raised by using the diagnostics view to help reduce your mean time to resolution of those same issues.
The focus of this post will be to help you gain valuable insights into the usage data of your applications so you can see statistics like top pages, number of page views, events and even slowest requests. You will also get information that helps you to understand the type of environments your end-users and customers are running when using your application. For me, this is probably the coolest service that Application Insights can deliver and if the availability and performance side of it doesn't rock your world , this should definitely be something of interest!
Configuring Usage
To get usage data for your application, you'll need to add some JavaScript code to it so Application Insights can start collecting this type of data. The process for configuring usage monitoring varies slightly depending on the type of application you are running (web site, web service, Windows Phone 8 app or Windows Store app) and for the purposes of this demo, I'll be walking through configuring the Fabrikam Fiber web site application that we deployed in my previous posts.
Logon to Visual Studio Online, open the Application Insights portal and click the 'Usage' view from the navigation bar.
Ensure your web application is selected from the drop-down menu, then click the 'Web site' button (or whichever button is relevant to your application type) as shown below.
You will be presented with five steps to help get your usage data configured and for now, we'll just move straight to Step 3 where we'll first make a copy of the JavaScript snippet provided.
Now logon to the server that's running your web application (this would be the demo web server that we created in Windows Azure in Part 2) and using Windows Explorer, browse to the location you've deployed it to (by default it should be C:\inetpub\wwwroot\Fabrikam).
Expand the 'Views' folder, then open the 'Shared' folder where you should see the '_Layout' CSHTML file. Right-click this file and edit it with a text editor such as Notepad++ as shown below.
Now, if you read the instructions from Step 3 of the Application Insights console where you copied the code snippet from, it tells you:
To collect usage data about your application, insert the following script into each page you wish to track. Place this code immediately before the closing </head> tag and before any script.
So we'll do just that and copy in our code snippet as shown in this graphic:
Once you've copied in the code snippet, save and close the file, then open up Application Insights again. Now all you have to do is to wait 20 or 30 minutes and your application should start lighting up in the Usage view.
Using the Application Insights Tools for Visual Studio 2013
An alternate (and even cooler) method of configuring your application for usage is to use the free Application Insights Tools for Visual Studio 2013. This option is only applicable when you've installed a local copy of Visual Studio 2013 and if you've already configured your application for usage monitoring by copying the code snippet from the steps above, the this method is not required.
To use the Application Insights Tools for Visual Studio 2013 (currently in preview), from the computer that you have Visual Studio 2013 installed on - open the Usage view from the Application Insights console, select your application type (web site for us), then click the download button from Step 1 as shown below.
This will open the download window for the tools....
Download the installer, run through the wizard...
Once it's finished, open your web application inside Visual Studio 2013 and right-click on the application from the Solution Explorer window to see the following context menu:
Click on the 'Add Application Insights telemetry to Project...' option and you'll be presented with this wizard...
Hit the blue button down the bottom of the wizard and the packages will be automatically downloaded and deployed to your web application.
Now wait for 20 - 30 minutes and your usage data will start showing up in the Application Insights console.
Exploring the Usage Views
Once you've configured your web application for usage monitoring, you can open the Application Insights console and click on the 'Usage' link to be presented with the 'Features\Top Pages' view as shown below:
Here you get a daily trend of Activities, Sessions, Unique Users and which pages they are accessing over a given period of time (you can modify the time range from the drop-down menu on the left).
Clicking on the 'Page Views' link from the navigation bar on the right-hand side will open a graph and table like this..
From the table above, you can see which pages your users are hitting and get statistics like the Average Number of Unique Users per day. You'll also see deployment markers in this graph which can come in quite handy before or after a new build.
Clicking on the 'Details' link (highlighted) from the same graph opens an hourly trend analysis of page views and sessions, performance counters and metrics.
If you click on the 'Events' link from the navigation bar, you'll be presented with events that have been logged by the client application and server, though this data is defined by the application itself and is up to the developer to decide on customisation.
Clicking on the 'Event Insights' link will enable you to analyse events so you get an understanding of how that event changes over time.
Another useful view is the 'Slowest Requests' one. Clicking this link gives you information on the average page load times (from the client application experience) of each page on a given date or time.
User Information
If you want to gain insight into data about the type of users that are visiting your web application, then click on the 'Users' option from the top navigation bar and select the 'Active Users' link from the left-hand side to get the following view:
From here you get information like the trend of active daily users, the frequency of their visits, the percentage of new visitors versus returning visitors and even their engagement level - which will show you how active your users are when they visit the site.
The links to the right of the 'Trend of active users by day' graph are live and you can click on them to change the data that the graph shows as below..
Clicking the 'Authenticated Active Users' link on the right will display similar information with the exception that it is targeted only at users that have been authenticated within the application.
If you want to dive into the 'Loyalty' view from the navigation bar on the left, you will be presented with a number of graphs and charts that show visitor loyalty and return trends like these examples..
Environment Types
Clicking on the 'Usage\Environment' links from the top navigation bar will take you to one of my favourite views in Application Insights.
It's here that we can see the different environment types that are being used to access our applications such as:
Operating Systems
Browsers
Even the language that your users are viewing in..
So that pretty much wraps up Monitoring Usage in Application Insights and in Part 7 I'll discuss working with Dashboards.
Terrific series!
ReplyDeleteCheers Walter :)
DeleteTerrific series!
ReplyDelete