Lesson 5 of 5 Azure Monitoring Tools

Monitoring Applications with Application Insights

This lesson explains Application Insights, how applications send it telemetry, and the features it provides for diagnosing performance problems and failures.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the purpose of Application Insights.
  • Identify the telemetry that Application Insights collects.
  • Distinguish application monitoring from infrastructure monitoring.

What Application Insights is

Application Insights, an Azure Monitor feature, monitors your web applications. It is capable of monitoring applications that are running in Azure, on-premises or in a different cloud environment. While Azure Monitor's platform metrics show how the infrastructure is doing, Application Insights shows how the application itself behaves from the perspective of its users: how fast it responds, which requests fail and why, and how people use it.

Application Insights stores its telemetry in a Log Analytics workspace (workspace-based resources), so application data can be queried with KQL together with other logs. Applications connect to an Application Insights resource with a connection string.

How applications send data

There are two ways to configure an application to send data to Application Insights:

  • Autoinstrumentation: for many hosting environments, such as Azure App Service, Azure Functions and VMs, monitoring can be turned on without changing the application's code, often with a setting in the portal.
  • Code-based instrumentation: adding the Azure Monitor OpenTelemetry Distro or an SDK to the application's code, which also allows custom events and metrics.

Application Insights can also run availability tests, which periodically send web requests to the application from points around the world and alert you if it does not respond or responds too slowly, even when no real users are active.

Scenario questions

Instrumenting an application

Exam skills 3.4.3

Choose how to collect application telemetry in each case.

Log in to try this activity Interactive activities are free with an account.

What Application Insights monitors

Application Insights collects a wide range of telemetry. The following table lists the main kinds and what they reveal.

TelemetryWhat it reveals
Request rates, response times and failure ratesWhich pages or API operations are most popular, slowest or failing
Dependency rates, response times and failure ratesWhether external services, such as databases or APIs, are slowing the application down
ExceptionsErrors in server and browser code, with stack traces for diagnosis
Page views and load performanceWhat users' browsers report about page loading
User and session countsHow many people use the application and how they move through it
Performance countersCPU, memory and network usage of the servers running the application

Features such as the application map, which shows the components of an application and the calls between them, live metrics for real-time monitoring, and smart detection of anomalies help teams find and fix problems quickly.

Match the pairs

Application telemetry

Exam skills 3.4.3

Match each kind of telemetry with what it reveals.

Log in to try this activity Interactive activities are free with an account.
Worked example

Diagnosing a slow application

Customers complain that a web application hosted on Azure App Service is sometimes slow and occasionally shows errors. The developers want to see which requests are slowest, whether calls to the application's database are the cause, and the exceptions behind the errors, preferably without changing code. Which tool should they use?

Enable Application Insights for the App Service app with autoinstrumentation. It records request response times and failure rates, dependency calls to the database with their durations, and exceptions with stack traces, and the application map shows where time is spent. Azure Service Health would show Azure platform issues rather than application behaviour, and VM metrics alone would not show which requests or dependencies are slow.

Check yourself

Can Application Insights monitor applications hosted outside Azure?

Show answer

Yes. It monitors web applications running in Azure, on-premises or in other clouds.

Exam Tips

Remember for the exam

  • Application Insights monitors web applications in Azure, on-premises or other clouds.
  • It tracks requests, response times, failures, dependencies, exceptions, page views and users.
  • Autoinstrumentation enables monitoring without code changes; availability tests check the app from around the world.