Monitoring App Services

Effective monitoring is crucial for understanding the health, performance, and resource utilization of your application services. This guide outlines the key tools and metrics available for monitoring your app services, helping you to proactively identify and resolve issues.

Key Monitoring Areas

When monitoring app services, focus on these core areas:

Tools and Features

Azure Application Insights

Azure Application Insights is a powerful Application Performance Management (APM) service that is integrated with Azure App Service. It provides rich telemetry about your application's performance and usage.

Key features of Application Insights include:

Azure Monitor

Azure Monitor is a comprehensive solution for collecting, analyzing, and acting on telemetry from your Azure and on-premises environments. It provides a unified view of application health and performance.

Key components of Azure Monitor for App Services:

Configuring Monitoring

Enabling Application Insights

To enable Application Insights for your App Service:

  1. Navigate to your App Service in the Azure portal.
  2. Under the "Monitoring" section, select "Application Insights".
  3. Click "Turn on Application Insights".
  4. Choose an existing Application Insights resource or create a new one.
  5. Click "Apply".

Configuring Diagnostic Logs

You can configure diagnostic logs to capture detailed information about your App Service:

  1. Navigate to your App Service in the Azure portal.
  2. Under the "Monitoring" section, select "Diagnostic logs".
  3. Choose the log categories you want to collect (e.g., AppServiceHTTPLogs, AppServiceAppLogs).
  4. Select a destination for your logs, such as a Storage account, Log Analytics workspace, or Event Hub.
  5. Click "Save".

Common Monitoring Metrics

Here are some of the most important metrics to monitor for your App Services:

Metric Description Typical Threshold
CPU Percentage The percentage of CPU utilized by the App Service instance. < 70-80% (sustained)
Memory Working Set The amount of physical memory used by the App Service instance. < 80% of allocated memory
HTTP 5xx Errors The number of server-side errors (5xx status codes) returned by the application. 0 or very low
HTTP 4xx Errors The number of client-side errors (4xx status codes) returned by the application. Low and indicative of expected user behavior.
Requests The total number of HTTP requests received by the App Service. Monitor trends and spikes.
Response Time The average time taken to respond to HTTP requests. As low as possible, typically under 1-2 seconds.
Data In/Out The amount of data transferred over the network by the App Service. Monitor for unexpected spikes.

Example: Setting up an alert for High CPU Usage

To set up an alert when CPU Percentage exceeds 80% for 15 minutes:

  1. Go to your App Service in the Azure portal.
  2. Under "Monitoring", select "Alerts".
  3. Click "Create rule".
  4. Scope: Select your App Service.
  5. Condition:
    • Signal type: Metrics
    • Signal name: CPU Percentage
    • Alert logic: Threshold - Static
    • Operator: Greater than
    • Threshold value: 80
    • Aggregation granularity (Period): 5 Minutes
    • Frequency of evaluation: 1 Minute
  6. Actions: Configure an action group (e.g., send an email, trigger a webhook).
  7. Details: Name your alert rule (e.g., "AppService-HighCPU-Alert").
  8. Click "Create rule".
Important: Regularly review your monitoring data and alerts. Proactive analysis can prevent major outages and improve the overall user experience.

By leveraging Azure Application Insights and Azure Monitor, you can gain deep insights into the behavior of your app services, ensuring their stability and performance.