Monitoring Your App Services
Effective monitoring is crucial for ensuring the health, performance, and availability of your applications hosted on App Services.
Introduction to App Services Monitoring
App Services provides a comprehensive suite of tools and features to monitor your applications. This includes tracking key performance indicators (KPIs), analyzing logs, and setting up alerts for potential issues.
Key Monitoring Features
- Metrics: App Services collects a variety of metrics that offer insights into your application's performance, such as CPU usage, memory consumption, network traffic, and request counts.
- Logs: Access application logs, web server logs, and deployment logs to diagnose problems and understand application behavior.
- Application Insights: For deeper diagnostics and performance analysis, integrate Application Insights to gain insights into request failures, response times, dependency tracking, and live metrics.
- Alerts: Configure alerts based on specific metric thresholds or log events to be notified proactively when issues arise.
- Diagnose and Solve Problems: A built-in troubleshooting tool that analyzes your app's configuration and runtime to identify and suggest solutions for common problems.
Viewing Metrics
You can view metrics directly from the Azure portal:
- Navigate to your App Service resource in the Azure portal.
- In the left-hand menu, under the 'Monitoring' section, select 'Metrics'.
- Choose the desired metric, aggregation type, and time range to analyze your application's performance over time.
Commonly Monitored Metrics:
- HTTP Server Errors: Tracks the number of HTTP requests that resulted in a server-side error (5xx).
- CPU Time: The total CPU time consumed by the App Service instance.
- Memory Working Set: The amount of physical memory currently used by the App Service.
- Requests: The total number of HTTP requests received by the App Service.
- Data In/Out: Network traffic flowing into and out of the App Service.
Working with Logs
App Services supports several types of logs:
- Application Logging: Logs generated by your application code. Enable this in the App Service settings to capture custom logs.
- Web Server Logging: Logs from the underlying web server (e.g., IIS).
- Detailed Error Messages: Provides more detailed information about HTTP errors.
- Failed Request Tracing: Captures detailed traces for failed HTTP requests.
Accessing Logs:
Logs can be accessed via:
- Log Stream: Real-time log viewing directly in the Azure portal.
- Kudu/Advanced Tools: Access log files stored on the App Service file system.
- Storage Account: Configure logs to be archived to an Azure Storage Account for long-term retention and analysis.
# Example of enabling Application Logging in Azure CLI
az webapp log config --name <your-app-name> --resource-group <your-resource-group> --application-logging on --level Information
Alerting
Set up alerts to notify you when certain conditions are met, allowing for rapid response to performance degradation or service outages.
- Navigate to your App Service resource.
- In the left-hand menu, under 'Monitoring', select 'Activity Log' and then 'Alerts'.
- Click '+ Create alert rule'.
- Define the scope, conditions (based on metrics or logs), and actions (e.g., email notification, webhook).
Best Practice
Configure alerts for critical metrics like HTTP Server Errors, CPU Time exceeding 80%, and Memory Working Set approaching capacity. Also, set up alerts for application-specific error logging.
Diagnose and Solve Problems
This integrated tool can automatically detect common issues like high CPU usage, memory leaks, and deployment failures. It provides step-by-step guidance and recommendations for resolution.
- Navigate to your App Service resource.
- In the left-hand menu, under 'Monitoring', select 'Diagnose and solve problems'.
- Review the suggested analyses or run custom diagnostics.
Common Diagnostic Categories:
- Availability and Performance
- Application Crashes
- HTTP 5xx Errors
- Deployment Issues