Azure App Service Monitoring

Azure provides various monitoring features to ensure the health and performance of your App Service applications. Monitoring is crucial for understanding resource usage, diagnosing issues, and optimizing performance.

Quotas

Each App Service is subject to specific resource limits defined by the App Service plan. When creating an App Service plan, you select a pricing tier and size, which determines the allocated resources. Key quotas include:

For Free or Shared Apps:

  • CPU (Short): Limits on CPU usage over short periods.
  • CPU (Day): Daily CPU usage limits.
  • Memory: Maximum memory usage allowed.
  • Bandwidth: Limits on data transfer.
  • Filesystem: Applicable for Basic, Standard, and Premium plans.

For Basic, Standard, and Premium Plans:

  • Filesystem Quota: Based on the number of App Service plans created in your subscription.

Metrics

Metrics provide insights into the behavior of your App Service applications and the underlying App Service plan. Metrics are available at two levels:

  1. App Service Plan Level:
    • CPU and Memory Percentage: Usage statistics for CPU and memory.
    • Data In and Out: Total data transferred to and from the app.
    • Disk Queue Length: Number of requests waiting to be processed by the disk.
    • HTTP Queue Length: Number of requests waiting to be processed by the web server.
  2. Application Level:
    • Average Response Time: Time taken to respond to requests.
    • Average Memory Working Set: Memory used by the application.
    • CPU Time: Total CPU time consumed by the application.
    • Data In and Out: Similar to App Service plan level but specific to the application.

Granularity and Retention

Metrics retention varies by granularity:

  • Minute Granularity: Retained for 30 hours.
  • Hour Granularity: Retained for 30 days.
  • Day Granularity: Retained for 30 days.

Using Application Insights can extend retention periods and provide more detailed metrics.


Diagnostics

Azure App Service provides diagnostic features for logging information from the web server and application. Diagnostics are split into two categories:

1. Web Server Diagnostics:

  • Detailed Error Logging: Logs HTTP errors (400 and above) for troubleshooting.
  • Failed Request Tracking: Provides traces of IIS components used to process requests.
  • Web Server Logging: Metrics on the total number of HTTP requests received and the originating IP addresses.

2. Application Diagnostics:

  • Captures information produced by the web application.
  • Allows for logging of diagnostic traces for monitoring application behavior.

Storage Options: Diagnostic information can be stored in the file system or Azure Storage for persistence.


Stream Logs

Real-time logging is essential during application development for immediate feedback. Azure provides options to stream log information directly to your development environment using either Azure PowerShell or the Azure Command-Line Interface (CLI).

Commands for Streaming Logs:

Streaming with Azure PowerShell:

powershell

Get-AzureWebSiteLog -Name webappname -Tail Get-AzureWebSiteLog -Name webappname -Tail -Message Error

Streaming with Azure Command-Line Interface:

bash

az webapp log tail --name webappname --resource-group myResourceGroup az webapp log tail --name webappname --resource-group myResourceGroup --filter Error