Azure Application Insights – An essential part of Microsoft DevOps Strategy

Posted by: Subodh Sohoni , on 1/22/2017, in Category Microsoft Azure
Views: 29454
Abstract: An overview of Application Insights, an Azure based service which makes it possible to monitor any application to know about its availability, failures and performance.

DevOps can be defined as extending agile practices to operations. An important part of ‘Operations’ is to monitor the health and performance of the software after it is deployed to production, and provide a feedback about it to the development team. Microsoft has built an Azure based infrastructure with tools to monitor, collect data and analyze health and performance of applications. This service offered by Azure is called Application Insights.

 

In this article, I am going to document some of the important details related to Application Insights. This article will cover:

  • How to install and enable Application Insights for a web application?
  • What monitoring data is collected by Application Insights?
  • How the collected data is reported?
  • How does Application Insights allow us to analyze that data?

Application Insights and DevOps

Software Operations was done by a separate team (other than the development team).

For the understanding of developers, let me first enumerate activities that are done by the operations team:

  • Provisioning – Operations team builds the environment to which the deployment is to take place. Tasks under that activity are
    • Create the virtual machines or take the existing virtual machines back to pristine stage
    • Install required prerequisites and configure them
    • Configure supporting software like WinRM, if required
    • Create necessary user accounts and groups. Set permissions for them.
  • Deployment – Copy files on target machines and install any of the binaries if needed.
  • Feedback and Testing – Run the application and do smoke tests. Do exploration of the application after deployment on the target machine to ensure the sanity of the software. Run automated tests if configured and send the results back to development team.
  • Health monitoring – Continuously monitor the availability, performance and other parameters to optimize the product.

The entire development and operations cycle could be depicted like this:

devops-cycle

Figure 1 - DevOps Cycle

Today we are going to set focus on the health monitoring of the deployed application. As part of the health monitoring, I am expecting the following features:

  • Continuous check for availability of the application
  • Time-to-time monitoring to know the performance of the application
  • Status of the components of the product and the servers on which they are deployed
  • Faults and errors including those of dependencies of product

As a team member of development team, I also would like to get some statistics and analysis of the usage of the product or the application. Statistics that I expect is for requests that are received by the application, page views, clients, exceptions etc.

Microsoft has created a service in Azure that is called Application Insights that provides health and performance monitoring, with analytics. Any application that can access Internet can publish the data for Application Insights. It can be ASP.NET web application hosted in cloud, or on a server in premises, or any other type of windows application including windows services or a Java web application and so on.

Today, we are going to take the case of Application Insights for an ASP.NET Web Application hosted in the App Services of the Microsoft Azure Cloud.

Enable Application Insights for an ASP.NET application

For an application to publish data to Application Insights, we need to add Application Insights SDK to it. This can be done while the application is created in Visual Studio, or afterwards, when it is ready to be published.

add-application-insights-sdk

Figure 2 – Add Application Insights SDK to the application in Visual Studio

Once the application is ready to publish the Application Insights data, it needs to be registered to the Application Insights service of Azure.

I am assuming here that an Azure account is already created and available.

register-app-for-application-insights

Figure 3 – Register application with Application Insights

As soon as the application is registered with Application Insights and starts running (even in debug mode in Visual Studio), it starts publishing data. We can observe this data on Application Insights of the Azure portal. The default blade of Application Insights shows overview of data related to health of the application, and requests received for each page of the application.

health-and-request-performance

Figure 4 – Health and performance overview of the application

Details of the data collected and reported by Application Insights

Each of the blades of Application Insights provides us with a different perspective to data that is collected. It is an analysed view of the data in a graphical format. We can set the begin and end timestamp to set the scope of analysis on the timeline.

Application Map – This blade shows us graphics of various components of the application, and related statistics. It also shows summary of the status of each component. That summary includes the requests or calls received, performance per request, errors or failures and link to drilldown for details of these parameters.

application-insights-application-map

Figure 5 – Application Map

Live Metrics Stream – It is a dashboard of live data being collected from the application. It shows the data related to:

  • Incoming Requests
    • Requests Per Second
    • Request Duration
    • Requests Failed per second
  • Outgoing Requests
    • Dependency calls per second (e.g. SQL Server Database Calls)
    • Dependency call duration
    • Dependency call failures
  • Overall Health
    • Memory Usage
    • CPU Usage
    • Unhandled Exceptions Per Second
  • Servers
    • For each Server, all the above 9 parameters are used
  • Recent Failures with drilldown to the exception details if available or request details

live-metrics-stream

Figure 6 – Live Metrics Streams Dashboard

Availability – To check availability, Application Insights uses web tests that run at a predetermined periodicity. Initially there are no web tests available for us and we need to create at the least one web test for collecting the availability data. In Figure 7, you can see that we can set the frequency at which the test will execute, success criteria, alert criteria etc. This test will be run at a time from 5 locations. Failure of test from 3 locations will send an alert for failure of test.

create-edit-web-test

Figure 7 – Add a web test to gather availability data

Once the test is configured, we can view the availability metrics.

availability-metrics

Figure 8 – Availability Metrics

Failures – This metrics shows following details of failures

  • Request failures (Any http response with response code more than 400)
  • Application exception that are not handled
  • Dependency failures
  • Server exceptions
  • Page faults
  • Details of all exceptions and requests in the specified time period

application-failures-1

Figure 9 – Failures metrics

Performance – This blade shows the following performance details:

  • Server response time
  • Dependencies response time
  • Per operation loading time
  • Dependency response average time

application-performance

Figure 10 – Performance Metrics

Browser – To enable browser side metrics, certain code has to be added to the master page of the site. That code is as follows:

add-client-side-telemetry

Figure 11 – Code to enable browser metrics

Browser metrics show the data related to the client application. Those metrics are:

  • Page view load time
  • Page views
  • Client processing time
  • Send request time
  • Receive response time
  • Page load networking time (time required for DNS Lookup and transport connection)
  • Operation time on each page

browser-related-metrics

Figure 12 – Browser related metrics

Usage – This blade shows the data of:

  • Users
  • Sessions
  • Page views

usage-statistics

Figure 13 – Usage statistics

Application insights Analytics

Application Insights provides a powerful query mechanism to do custom analysis and view the results as a list or a graph. Analytics schema allows us to create query based upon the following data:

  • Traces
  • Custom Events
  • Page Views
  • Requests
  • Dependencies
  • Exceptions
  • Availability Results
  • Custom Metrics
  • Performance Counters
  • Browser Metrics

Queries use a special language that is similar to SQL. We can create a query graphically by first selecting the metrics to be queried, say pageViews. Then we can apply filters on that to get list or a graph of the results. For example, pageViews | where operation_name == “/” will show the results in a list / tabular form as in Figure 14.

application-insights-analytics

Figure 14 – A simple query and its tabular results

We can also view the results in a graphical form. A query on availabilityResults summarized by location of test, shows a pie chart as in Figure 15.

custom-query-results-graphics

Figure 15: Simple query results in graphical form

For knowing more about Application Insights Analytics visit https://docs.microsoft.com/en-us/azure/application-insights/app-insights-analytics

Application Insights Alerts

Application Insights also facilitates setting email alerts for various conditions. For example, we can set alert for availability based upon the web test that we had created. We can set a threshold limit and if availability is below the limit, we can have an email delivered to us by Application Insights.

alert-setting

Figure 16 – Setting alert for availability going below threshold

This alert will look like the one shown in Figure 17.

average-availability-below-threshold-alert

Figure 17 – Availability below threshold limit alert

Conclusion

DevOps strategy cannot be complete without monitoring and analyzing the health and performance of the application that is deployed.

Microsoft has provided Application Insights, an Azure based service which makes it possible to monitor any application to constantly know availability of the application, failures and performance. It also provides an easy interface to query and analyse data for creating tabular and graphical reports.

For critical conditions, Application Insights, can also be configured to send alerts to our email addresses.

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Author

Subodh is a Trainer and consultant on Azure DevOps and Scrum. He has an experience of over 33 years in team management, training, consulting, sales, production, software development and deployment. He is an engineer from Pune University and has done his post-graduation from IIT, Madras. He is a Microsoft Most Valuable Professional (MVP) - Developer Technologies (Azure DevOps), Microsoft Certified Trainer (MCT), Microsoft Certified Azure DevOps Engineer Expert, Professional Scrum Developer and Professional Scrum Master (II). He has conducted more than 300 corporate trainings on Microsoft technologies in India, USA, Malaysia, Australia, New Zealand, Singapore, UAE, Philippines and Sri Lanka. He has also completed over 50 consulting assignments - some of which included entire Azure DevOps implementation for the organizations.

He has authored more than 85 tutorials on Azure DevOps, Scrum, TFS and VS ALM which are published on www.dotnetcurry.com.Subodh is a regular speaker at Microsoft events including Partner Leadership Conclave.You can connect with him on LinkedIn .


Page copy protected against web site content infringement 	by Copyscape




Feedback - Leave us some adulation, criticism and everything in between!