MSDN Documentation

Application Insights Overview

Application Insights is a powerful and extensible Application Performance Management (APM) service for web developers. It helps you understand how your live applications are performing, and to actively detect and diagnose issues with them. Use Application Insights to continuously improve performance and usability by detecting issues, diagnosing crashes, and understanding user behavior.

Key Features:

  • Automatic instrumentation for many popular frameworks.
  • Rich set of metrics and diagnostics.
  • Custom telemetry tracking.
  • Integration with Azure services.
  • Proactive issue detection and alerting.

What is Application Insights?

Application Insights is part of the Azure Monitor suite, providing deep visibility into your application's performance and usage. It collects telemetry data from your application, allowing you to analyze trends, identify bottlenecks, and troubleshoot errors efficiently.

Core Telemetry Types

Application Insights collects various types of telemetry data:

  • Requests: Inbound requests to your application, including response times and success rates.
  • Dependencies: Outbound calls made by your application to other services, such as databases or REST APIs.
  • Exceptions: Unhandled exceptions occurring within your application.
  • Performance Counters: System performance metrics like CPU usage, memory, and network traffic.
  • Traces: Custom log messages emitted by your application.
  • Events: Custom events to track user interactions or specific application activities.

Getting Started

To start using Application Insights, you typically need to:

  1. Create an Application Insights resource in the Azure portal.
  2. Instrument your application by adding the Application Insights SDK or using autocollection features.
  3. Deploy your application and start monitoring its telemetry.

Example: Basic SDK Configuration (C#)


using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;

// ...

// Initialize TelemetryConfiguration
var telemetryConfiguration = TelemetryConfiguration.CreateDefault();
telemetryConfiguration.ConnectionString = "YOUR_CONNECTION_STRING"; // Replace with your actual connection string

// Create a TelemetryClient
var telemetryClient = new TelemetryClient(telemetryConfiguration);

// Track a custom event
telemetryClient.TrackEvent("UserLoggedIn");

// Track a dependency
telemetryClient.TrackDependency("MyDatabase", "GetData", TimeSpan.FromMilliseconds(150), true);

// Track an exception
try
{
    // ... code that might throw an exception
}
catch (Exception ex)
{
    telemetryClient.TrackException(ex);
}
                    

Key Capabilities

Performance Monitoring

Identify slow-running operations, diagnose latency issues, and pinpoint performance bottlenecks. Application Insights provides detailed breakdowns of request times, dependency durations, and server response times.

Availability Monitoring

Set up web tests to proactively monitor the availability and responsiveness of your web applications from various locations around the world.

Usage Analysis

Understand how users interact with your application. Track page views, custom events, and user flows to gain insights into user behavior and popular features.

Failure Diagnostics

Automatically detect and analyze exceptions, including stack traces and relevant context, to quickly diagnose and resolve errors.

Integration with Azure

Application Insights integrates seamlessly with other Azure services, including:

  • Azure Monitor: For unified monitoring and alerting.
  • Azure App Services: For easy deployment and configuration.
  • Azure Functions: For serverless application monitoring.
  • Azure Kubernetes Service (AKS): For containerized application monitoring.

Next Steps

Explore the following resources to deepen your understanding: