Skip to content

๐Ÿ“Š Monitoring an IIS-Based Web Farm with Azure Application Insights

In this guide, you'll learn how to:

โœ… Set up Application Insights on an IIS-based web farm.
โœ… Configure Log Analytics, Data Collection Rules, and Data Collection Endpoints.
โœ… Use PowerShell to install the Application Insights agent.
โœ… Monitor live metrics, failures, performance, and logs in real-time.

By the end, you'll have a fully monitored IIS-based web farm using Azure! ๐ŸŽฏ


๐Ÿ—๏ธ Step 1: Enabling Application Insights on IIS Servers

To effectively monitor your IIS-based application, you need to configure Azure Application Insights and ensure all required components are installed on your Azure VMs.

๐Ÿ› ๏ธ Prerequisites

Before proceeding, ensure you have:

  • An active Azure Subscription with permissions to create and manage resources.
  • A Log Analytics Workspace (LAW) to store collected telemetry data.
  • Azure Monitor Agent (AMA) installed on your IIS VMs.
  • Necessary permissions to create Data Collection Rules (DCRs) and Data Collection Endpoints (DCEs).

Create a Log Analytics Workspace

  1. Go to Azure Portal โ†’ Search for "Log Analytics Workspaces" โ†’ Create.
  2. Provide the following details:
  3. Subscription: Select your Azure subscription.
  4. Resource Group: Choose or create a new one.
  5. Name: Enter a unique name (e.g., log-corpapp-prod-uksouth).
  6. Region: Same as your IIS VMs.
  7. Click "Review + Create" and deploy the workspace.

๐Ÿ”— Microsoft Learn: Log Analytics Workspace

Create a Data Collection Endpoint (DCE)

  1. Navigate to Monitor โ†’ Data Collection Endpoints.
  2. Click "+ Create" and provide:
  3. Name: e.g., dce-corpapp-prod-uksouth.
  4. Subscription & Resource Group: Same as your IIS VMs.
  5. Region: Same as Log Analytics Workspace.
  6. Review & create the endpoint.

๐Ÿ”— Microsoft Learn: Data Collection Endpoints

Create a Data Collection Rule (DCR)

  1. Go to Monitor โ†’ Data Collection Rules โ†’ + Create.
  2. Configure:
  3. Name: dcr-corpapp-iis-prod-uksouth
  4. Subscription & Resource Group: Same as above.
  5. Region: Same as DCE & LAW.
  6. Define data sources:
  7. Windows Event Logs: Add System, Application, etc.
  8. Log Levels: Select relevant levels (Error, Warning, Information).
  9. Set Destination:
  10. Choose "Log Analytics Workspace" โ†’ Select the previously created workspace.
  11. Associate with IIS VMs (WEB01 - WEB05).
  12. Review & Create the rule.

๐Ÿ”— Microsoft Learn: Data Collection Rules

Install the Azure Monitor Agent (AMA)

  1. Navigate to each IIS VM.
  2. Under "Monitoring", select "Extensions".
  3. Click "+ Add" โ†’ AzureMonitorWindowsAgent โ†’ Install.
  4. Repeat for all IIS VMs.

๐Ÿ”— Microsoft Learn: Azure Monitor Agent

Enable Application Insights

  1. Navigate to Azure Portal โ†’ Search for "Application Insights".
  2. Click "+ Create" โ†’ Provide:
  3. Subscription & Resource Group: Same as VMs.
  4. Name: insights-corpapp-prod-uksouth-001.
  5. Region: Same as your IIS VMs.
  6. Application Type: ASP.NET Web Application.
  7. Click "Review + Create" and deploy.

๐Ÿ”— Microsoft Learn: Enable Application Insights

Install the Application Insights Agent

Use the following PowerShell script to install the agent on all of the IIS servers:

# Install the Application Insights Agent
$instrumentationKey = "YOUR-INSTRUMENTATION-KEY"
Install-PackageProvider -Name NuGet -Force
Install-Module -Name ApplicationInsightsWebTracking -Force
Enable-ApplicationInsightsMonitoring -InstrumentationKey $instrumentationKey
Restart-Service W3SVC

๐Ÿ“Š Step 2: Using Application Insights for Monitoring

With everything set up, it's time to monitor and analyze application performance! ๐Ÿ”

๐Ÿ“Œ Overview Dashboard

  • Displays high-level health metrics, failed requests, and response times. ๐Ÿ“ธ Insights Overview

๐Ÿ“Œ Application Map

  • Shows dependencies and interactions between components. ๐Ÿ“ธ Application Map

๐Ÿ“Œ Live Metrics

  • Monitor real-time requests, server performance, and failures. ๐Ÿ“ธ Live Metrics

๐Ÿ“Œ Failures & Exceptions

  • Identify and diagnose failed requests & top exceptions. ๐Ÿ“ธ Failures & Exceptions

๐Ÿ“Œ Performance Monitoring

  • Analyze response times, dependencies & bottlenecks. ๐Ÿ“ธ Performance Overview

๐Ÿ“Œ Logs & Queries

  • Run Kusto Query Language (KQL) queries for deep insights.

Example query to find failed requests:

requests
| where timestamp > ago(24h)
| where success == false
| project timestamp, name, resultCode, url
| order by timestamp desc

๐Ÿ“ธ Query Results


โœ… Next Steps

๐ŸŽฏ Continue monitoring logs & alerts for trends.
๐ŸŽฏ Optimize Application Insights sampling to reduce telemetry costs.
๐ŸŽฏ Automate reporting for key performance metrics.

By following this guide, you'll have a robust, real-time monitoring setup for your IIS web farm, ensuring optimal performance and quick issue resolution! ๐Ÿš€

Share on Share on