You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Application Insights is a feature of Azure Monitor that provides application performance management (APM) for your web applications and services. It automatically collects telemetry about requests, dependencies, exceptions, and performance, giving you deep visibility into how your applications behave in production.
Application Insights monitors your live applications and helps you:
| Capability | Description |
|---|---|
| Request tracking | Monitor response times, throughput, and failure rates |
| Dependency tracking | Track calls to databases, HTTP APIs, Azure services |
| Exception tracking | Capture exceptions with full stack traces and context |
| Live Metrics | Real-time telemetry stream during active investigation |
| Availability tests | Synthetic tests that check your app from multiple Azure regions |
| Application Map | Visual topology of your application and its dependencies |
| Smart Detection | ML-powered anomaly detection for failure rates and performance |
| User analytics | User flows, sessions, funnels, and retention analysis |
There are two ways to add Application Insights to your application:
Azure can automatically collect telemetry without code changes for supported platforms:
| Platform | Method |
|---|---|
| Azure App Service (.NET) | Enable in the Azure Portal — no code changes |
| Azure App Service (Java) | Enable Java agent in the Portal |
| Azure App Service (Node.js) | Enable in the Portal |
| Azure Functions | Built-in integration |
| Azure VMs | Install the Application Insights agent |
| AKS | Use the OpenTelemetry auto-instrumentation operator |
For more control, add the Application Insights SDK to your application code:
.NET:
// Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApplicationInsightsTelemetry();
Python:
from azure.monitor.opentelemetry import configure_azure_monitor
configure_azure_monitor(
connection_string="InstrumentationKey=<key>;IngestionEndpoint=https://uksouth-1.in.applicationinsights.azure.com/"
)
JavaScript / Node.js:
const { useAzureMonitor } = require('@azure/monitor-opentelemetry');
useAzureMonitor({
azureMonitorExporterOptions: {
connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
}
});
The SDK approach gives you the ability to add custom telemetry, custom properties, and fine-grained control over what is collected.
Application Insights collects several types of telemetry:
| Telemetry Type | Table in Log Analytics | Description |
|---|---|---|
| Requests | AppRequests | Incoming HTTP requests to your app |
| Dependencies | AppDependencies | Outgoing calls to databases, HTTP APIs, Azure services |
| Exceptions | AppExceptions | Unhandled and tracked exceptions |
| Page views | AppPageViews | Client-side page load events |
| Custom events | AppEvents | Business events you define |
| Custom metrics | AppMetrics | Numerical measurements you define |
| Traces | AppTraces | Diagnostic log messages |
| Availability | AppAvailabilityResults | Synthetic test results |
The Application Map provides a visual topology of your application, showing:
This is invaluable for understanding distributed applications and quickly identifying which component is causing issues.
Live Metrics provides a real-time telemetry stream with zero latency:
Live Metrics is particularly useful during active incidents or immediately after a deployment to verify that everything is working correctly.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.