To ensure seamless customer experience, organizations today must continuously monitor applications for anomalies, performance issues, and errors, as well as take remedial actions when needed. 

Application Insights is a solution from Azure Monitor that helps you achieve such monitoring as well as understand the usage of your application and user engagement via integrated analytics tools. The service works with a wide variety of application development platforms, such as .Net, Java, Python, and Node.js, hosted across both multiple cloud platforms and on-premises environments.

This blog will explore the features of Application Insights and how it can be leveraged by your developers and DevOps teams to gain visibility into application performance and usage.

Application Insights Architecture and Key Features

Application Insights uses an SDK that can be integrated with your application components in any of the supported platforms. This will help you pull telemetry data from multiple sources to generate visualizations, create alerts, or integrate with Azure monitor. You can also use the data collected to create an application map through a progressive discovery of dependent components. This helps in visualizing the dependencies of application components and drill down and isolate performance issues related to specific components. The high-level architecture of Application Insights can be seen below.

Azure Application Insights architecture diagram

Figure 1: Application Insights high-level architecture

Application Insights is capable of monitoring the following aspects of your application:

Application performance: Application Insights can collect specific application performance data like response rates, exception rates, failure rates, and page load delays. Additionally, you can also collect host diagnostics information from the Azure platform and performance counters (CPU/memory/network usage) from Windows/Linux servers, as well as containerized workloads that help identify application bottlenecks. Application Insights also helps capture exceptions, related to both the browser and server, and enables deeper analysis through stack traces.

Application availability: To monitor the availability of your applications, you can configure Application Insights to perform availability checks through web requests or ping tests. If you already have custom applications to track availability, those can also be integrated with Application Insights by leveraging the SDK. This way, the unavailability of applications and application response delays can be identified and alerts can be generated.

Application usage: The rich metrics available in Application Insights help you analyze user engagement via information, such as pages most accessed by users and peak access time. User and session count data is another metric available that enables you to better understand usage of the application. Moreover, correlating usage data with application performance metrics will help to isolate underlying resource constraints. 

Custom monitoring: In addition to the built-in metrics, customers can also write custom code and events to track specific application events using Application Insights. For example, you can track how a product is trending, the adoption of a new product feature, etc.

Integrating Application Insights with Your Application Stack

There are multiple options for integrating Application Insights with your application stack. Let’s explore the most commonly used ones in detail.

Runtime integration: This lightweight integration helps you integrate Application Insights with already deployed applications without having to update the code. It is available for ASP.NET or ASP.NET core applications deployed on Azure web apps or IIS-hosted ASP.NET applications deployed to Azure VMs and Azure VMSS as well as on-premises machines. 

For Azure-hosted applications, you can perform the configuration directly from the portal by enabling the Application Insights Agent. For on-premises applications, you must deploy the agent through a PowerShell module that can send the telemetry to Application Insights.

During development: The application insights SDK can be added to the code to enable telemetry during the early stages of application development. Microsoft provides detailed instructions on how to enable this for all supported application platforms. You can also choose not to send data to the portal during debugging and instead view the telemetry in Visual Studio.

Instrument web pages: You can use Application Insights to monitor the performance and usage of web pages by integrating a small JavaScript to the pages. When added, you can then monitor metrics such as user/session counts, AJAX calls/failures, page load duration, etc. 

Integration with a Web App 

To enable Application Insights for an existing web app in Azure, complete the steps, as outlined below.

  1. From the web app overview page, click on “Application Insights”:

getting to azure application insights

2. Click “Turn on Application Insights”:

3. A new Application Insights will be created for you, or you can choose to select an existing resource. In this demo, you’ll be creating a new Application Insights:

4. Scroll down to the instrumentation settings and make any changes needed for your monitoring requirement. For example, you can configure the collection level for APM visibility, enable a profiler to collect profiling traces, or use Snapshot Debugger to track exceptions. For this demo, you’ll leave the settings as default for the ASP.NET application.

Click on apply to update the changes:

5. Click “Yes” on the confirmation prompt to complete the configuration:

6. To enable client-side monitoring in the web app, browse to settings->configuration and click on “+New application setting”:

7. Add the following values to enable client-side monitoring (for .NET and .NET core applications):

Name: APPINSIGHTS_JAVASCRIPT_ENABLED
Value: true

Click “OK” to save the settings:

8. Browse to the newly created Application Insights to view the monitoring data and metrics. In the screenshot below, you can see metrics like failed requests, server response times, and server requests for the past hour:

9. The application dashboard feature provides a consolidated view of additional metrics, including details of unique sessions and users, failed requests, server response times, average available memory, average process I/O rate, and CPU utilization:

10. You can drill down to additional details by clicking on the metrics. For example, to view the page load performance, click on the “Average page load time breakdown” graph on the dashboard:

11. You can further fine-tune this to view specific metrics within the graph. For example, to view the “Browser page load time,” select that metric from the drop-down menu:

12. Application Insights can also provide live metrics for your website. Browse to Application Insights->Investigate->Live Metrics to view metrics such as incoming requests, duration of requests, failure rates, outgoing requests, dependency call requests, failures, overall application health, CPU usage, and exception rates. This feature is very helpful when you are troubleshooting problems live:

azure application insights live metrics dashboard

13. The “Investigate” section of Application Insights provides additional statistics on availability, failures, and performance. A sample graph for application access failures is shown below:

Investigate section of Azure Application Insights

And here is a sample graph for performance metrics, which can then be drilled down to the performance of specific pages in the application, i.e., response times to “GET” calls: 

azure application insights performance metrics graph

The Azure Application Insights Value Proposition

Application Insights delivers seamless monitoring and end-to-end integration with applications deployed across hybrid as well as cloud-native environments. This enables application monitoring from a single console, with rich visualization and analytics capabilities. Application Insights can also be integrated with log analytics to query logs and derive intelligence from telemetry data. Plus, customers can configure alerts based on the signals being monitored by Application Insights so that stakeholders are informed about any anomalies reported in the system. 

Application Insights is dependent on the SDK or Application Insights Agent to collate and send telemetry data to the service for further analysis. For non-cloud-native applications, this would involve additional effort, so it is recommended to start this early during the development cycle. Integration of Application Insights has minimal impact on your application performance, as the tracking calls are sent in separate non-blocking threads. The associated cost is pay-as-you-go; it charges customers only for the volume of telemetry data ingested and the number of tests configured for the application.

While Application Insights covers a wide range of scenarios and multiple development platforms, the support for monitoring applications in Docker is deprecated. Customers will have to use the “Azure Monitor for containers” solution for containerized applications.

Conclusion

Observability into your application stack is non-negotiable in modern-day cloud environments. Application Insights delivers this capability natively in Azure, with easy integration, deployment, and configuration options. With the proliferation of microservices-based architectures using containers in the cloud, additional solutions like Epsagon can also be explored for end-to-end visibility.

Read More:

Getting started with Azure Kubernetes Service (AKS)

Announcing Epsagon’s Applied Observability for Azure and K8s

Running Container Workloads: AWS vs. Azure vs. GCP (Part I)