Monitoring App Service
When you have critical applications and business processes relying on Azure resources, you want to monitor those resources for their availability, performance, and operation. This article describes the monitoring data generated by App Service and shipped to Azure Monitor. You can also use built-in diagnostics to monitor resources to assist with debugging an App Service app. If you're unfamiliar with the features of Azure Monitor common to all Azure services, read Monitoring Azure resources with Azure Monitor.
App Service collects the same kinds of monitoring data as other Azure resources that are described in Monitoring data from Azure resources.
See Monitoring App Service data reference for detailed information on App Service metrics and logs.
App Service also provides built-in diagnostics to assist with debugging apps. See Enable diagnostics logging for more information on enabling the built-in logs. To monitor App Service instances, see Monitor App Service instances using Health check.
Application Insights monitors the availability, performance, and usage of your web applications. It leverages the powerful data analysis platform in Azure Monitor to provide you with deep insights into your application's operations. It enables you to diagnose errors without waiting for a user to report them. Application Insights includes connection points to a variety of development tools and integrates with Visual Studio to support your DevOps processes. Learn more about Application Insights in the Application Monitoring for App Service Overview.
Collection and routing
Platform metrics and the Activity log are collected and stored automatically, but can be routed to other locations by using a diagnostic setting.
Resource Logs aren't collected and stored until you create a diagnostic setting and route them to one or more locations.
See Create diagnostic setting to collect platform logs and metrics in Azure for the detailed process for creating a diagnostic setting using the Azure portal, CLI, or PowerShell. When you create a diagnostic setting, you specify which categories of logs to collect. The categories for App Service are listed in App Service monitoring data reference.
The metrics and logs you can collect are discussed in the following sections.
Logs are grouped into Category groups. Category groups are a collection of different logs to help you achieve different monitoring goals.
The audit category group allows you to select the resource logs that are necessary for auditing your resource. For more information, see Diagnostic settings in Azure Monitor Resource logs.
You can analyze metrics for App Service with metrics from other Azure services using metrics explorer by opening Metrics from the Azure Monitor menu. See Analyze metrics with Azure Monitor metrics explorer for details on using this tool.
For a list of platform metrics collected for App Service, see Monitoring App Service data reference metrics
For reference, you can see a list of all resource metrics supported in Azure Monitor.
Data in Azure Monitor Logs is stored in tables where each table has its own set of unique properties.
All resource logs in Azure Monitor have the same fields followed by service-specific fields. The common schema is outlined in Azure Monitor resource log schema.
The Activity log is a type of platform log that provides insight into subscription-level events. You can view it independently or route to Azure Monitor Logs. Routing to Azure Monitor Logs gives the benefit of using Log Analytics to run complex queries.
For a list of types of resource logs collected for App Service, see Monitoring App Service data reference
For a list of queryable tables used by Azure Monitor Logs and Log Analytics, see Monitoring App Service data reference.
Sample Kusto queries
When you select Logs from the App Service menu, Log Analytics is opened with the query scope set to the current resource. This means that log queries will only include data from that resource. If you want to run a query that includes data from other [resource] or data from other Azure services, select Logs from the Azure Monitor menu. See Log query scope and time range in Azure Monitor Log Analytics for details.
The following sample query can help you monitor app logs using
AppServiceAppLogs | project CustomLevel, _ResourceId | summarize count() by CustomLevel, _ResourceId
The following sample query can help you monitor HTTP logs using
AppServiceHTTPLogs where the
HTTP response code is
500 or higher:
AppServiceHTTPLogs //| where ResourceId = "MyResourceId" // Uncomment to get results for a specific resource Id when querying over a group of Apps | where ScStatus >= 500 | reduce by strcat(CsMethod, ':\\', CsUriStem)
The following sample query can help you monitor HTTP 500 errors by joining
let myHttp = AppServiceHTTPLogs | where ScStatus == 500 | project TimeGen=substring(TimeGenerated, 0, 19), CsUriStem, ScStatus; let myConsole = AppServiceConsoleLogs | project TimeGen=substring(TimeGenerated, 0, 19), ResultDescription; myHttp | join myConsole on TimeGen | project TimeGen, CsUriStem, ScStatus, ResultDescription;
See Azure Monitor queries for App Service for more sample queries.
Azure Monitor alerts proactively notify you when important conditions are found in your monitoring data. They allow you to identify and address issues in your system before your customers notice them. You can set alerts on metrics, logs, and the activity log.
If you're running an application on App Service Azure Monitor Application Insights offers more types of alerts.
The following table lists common and recommended alert rules for App Service.
|Metric||Average connections||When number of connections exceed a set value|
|Metric||HTTP 404||When HTTP 404 responses exceed a set value|
|Metric||HTTP Server Errors||When HTTP 5xx errors exceed a set value|
|Activity Log||Create or Update Web App||When app is created or updated|
|Activity Log||Delete Web App||When app is deleted|
|Activity Log||Restart Web App||When app is restarted|
|Activity Log||Stop Web App||When app is stopped|