Log and Metrics in Azure Container Apps
Note
The Basic, Standard, and Enterprise plans will be deprecated starting from mid-March, 2025, with a 3 year retirement period. We recommend transitioning to Azure Container Apps. For more information, see the Azure Spring Apps retirement announcement.
The Standard consumption and dedicated plan will be deprecated starting September 30, 2024, with a complete shutdown after six months. We recommend transitioning to Azure Container Apps. For more information, see Migrate Azure Spring Apps Standard consumption and dedicated plan to Azure Container Apps.
This article applies to: ✅ Basic/Standard ✅ Enterprise
When you transition from Azure Spring Apps to Azure Container Apps, you find similar observability features but with some key differences. This article highlights these differences and explains how to monitor your applications in Azure Container Apps.
Prerequisites
- An existing Azure container app. For more information, see Quickstart: Deploy your first container app using the Azure portal.
- Azure CLI.
Logs
Configure logging options
Azure Container Apps enables you to manage logging in the Azure Container Apps environment.
You can store logs in both Azure Log Analytics and Azure Monitor. If you choose Azure Monitor, you find a diagnostics settings menu in the environment settings, similar to the one in Azure Spring Apps.
When you create an environment with the Azure CLI, as shown in the following example, an autogenerated Log Analytics workspace is provisioned.
az containerapp env create \
--resource-group MyResourceGroup \
--name MyContainerappEnvironment \
--location eastus2
You can also use the following command to create an environment with an existing Log Analytics workspace:
az containerapp env create \
--resource-group MyResourceGroup \
--name MyContainerappEnvironment \
--logs-workspace-id myLogsWorkspaceID \
--logs-workspace-key myLogsWorkspaceKey \
--location eastus2
Analyze logs
Azure Container Apps enables you to stream logs from your container console. The following list describes the main differences in logging:
Console logs: For console logs, query the
ContainerAppConsoleLogs_CL
table in Azure Container Apps instead of theApplicationConsole
table used in Azure Spring Apps.System logs: Azure Spring Apps provides
SystemLogs
for Config Server, Service Registry, API Portal, Application Configuration Service, and Spring Cloud Gateway. In Azure Container Apps, you need to provision these components as separate applications and query their logs in theContainerAppConsoleLogs_CL
table, specifying each app's name in your query.Build logs: Build logs from local builds with Paketo Buildpacks aren't available in Azure Container Apps, which differs from Azure Spring Apps.
View logs
By default, Azure Container Apps send logs directly to Azure Log Analytics. However, if you choose to store logs in Azure Monitor, the table and column names can differ. In Azure Monitor, table and column names don't include suffixes. For example, use ContainerAppConsoleLogs
instead of ContainerAppConsoleLogs_CL
and Log
instead of Log_s
when crafting queries for logs stored in Azure Monitor.
To view console logs in Azure Container Apps, use the following query as an example:
ContainerAppConsoleLogs_CL
| limit 50
Azure Log Analytics runs with a Kusto engine so you can query your logs for analysis. For an introduction to querying logs by using Kusto, see Log Analytics tutorial.
Show application logs
To review a list of application logs, sorted by time with the most recent logs shown first, use the following query:
ContainerAppConsoleLogs_CL
| project TimeGenerated, EnvironmentName_s, ContainerAppName_s, RevisionName_s, Log_s
| sort by TimeGenerated desc
Show log entries containing errors or exceptions
To review unsorted log entries that mention an error or exception, use the following query:
ContainerAppConsoleLogs_CL
| project TimeGenerated, EnvironmentName_s, ContainerAppName_s, RevisionName_s, Log_s
| where Log_s contains "error" or Log_s contains "exception"
Use this query to find errors, or modify the query terms to find specific error codes or exceptions.
Show the number of errors and exceptions reported by your application over the last hour
To create a pie chart that displays the number of errors and exceptions logged by your application in the last hour, use the following query:
ContainerAppConsoleLogs_CL
| where TimeGenerated > ago(1h)
| where Log_s contains "error" or Log_s contains "exception"
| summarize count_per_app = count() by ContainerAppName_s
| sort by count_per_app desc
| render piechart
Show Spring Cloud Gateway logs
To review log entries for Spring Cloud Gateway logs, use the following query:
ContainerAppSystemLogs_CL
| where ComponentType_s == "SpringCloudGateway"
| project TimeGenerated, ComponentType_s, EnvironmentName_s, ComponentName_s, Log_s
| limit 100
Show Eureka Server logs
To review log entries for Eureka Server logs, use the following query:
ContainerAppSystemLogs_CL
| where ComponentType_s == "SpringCloudEureka"
| project TimeGenerated, ComponentType_s, EnvironmentName_s, ComponentName_s, Log_s
| limit 100
Metrics
The following tables map metrics between Azure Spring Apps and Azure Container Apps:
Common
Azure Spring Apps metric name | Azure Container Apps metric name |
---|---|
App CPU Usage | N/A |
App Memory Usage | N/A |
App Network In | N/A |
App Network Out | N/A |
Error metrics
Azure Spring Apps metric name | Azure Container Apps metric name |
---|---|
tomcat.global.error |
N/A |
Performance metrics
Azure Spring Apps metric name | Azure Container Apps metric name |
---|---|
system.cpu.usage |
CPU Usage Percentage (Preview) |
process.cpu.usage |
N/A |
App Memory Usage | N/A |
jvm.memory.committed |
jvm.memory.committed |
jvm.memory.used |
jvm.memory.used |
jvm.memory.max |
N/A |
Additional JVM Metrics | N/A |
.NET performance metrics
Azure Spring Apps metric name | Azure Container Apps metric name |
---|---|
CPU usage | CPU Usage Percentage (Preview) |
Working set | Memory Working Set Bytes |
GC Heap Size | N/A |
Gen 0 GC count | N/A |
Additional GC Metrics | N/A |
Request metrics
Azure Spring Apps metric name | Azure Container Apps metric name |
---|---|
tomcat.global.sent |
N/A |
tomcat.global.request.total.count |
Requests |
.NET request metrics
Azure Spring Apps metric name | Azure Container Apps metric name |
---|---|
Requests per second | N/A |
Total requests | Requests |
Session metrics
Azure Spring Apps metric name | Azure Container Apps metric name |
---|---|
tomcat.sessions.active.max |
N/A |
tomcat.sessions.alive.max |
N/A |
Java metrics for Java apps in Azure Container Apps
If you choose Java as the development stack for Azure Container Apps, monitoring Java Virtual Machine (JVM) metrics is essential to ensure the health and performance of your applications. For more information, see Java metrics for Java apps in Azure Container Apps.
Managed components
For managed components monitoring data, see the following articles:
Integration
Azure Container Apps offers several built-in observability features to help you monitor and diagnose the state of your application. However, if you want to use Azure Monitor Application Insights or other application performance monitoring (APM) agents, you need to add instrumentation to your application code.
Integrate with application performance monitoring
For the integration with Azure Monitor Application Insights or other APMs, see Integrate application performance monitoring into container images.
OpenTelemetry agents (preview)
You can send observability data in an OpenTelemetry format to destinations like Azure Monitor Application Insights, Datadog, or any OTLP-compatible endpoint using an OpenTelemetry data agent with your Azure Container Apps environment. The managed agent simplifies configuration by letting you change destination endpoints without manually running or reconfiguring the agent. To set it up, configure the agent in your container environment using ARM templates, Bicep, or the Azure CLI, and prepare your application by installing the OpenTelemetry SDK and instrumenting your code for metrics, logs, or traces. Be sure to set up the destination service beforehand, such as Application Insights. Each destination has specific requirements, and the agent sends data only if properly configured and instrumented. For more information, see Collect and read OpenTelemetry data in Azure Container Apps.
Custom dashboards and alerts
When you deploy applications on Azure Container Apps, your custom dashboards can rely on two different data sourcing approaches:
App-integrated APM agents: If you integrated third-party APM agents into your application during the build process, these agents send metrics and logs directly to the APM platform. In this case, as long as your application code remains unchanged, you don't need to modify your dashboards.
Azure Monitor-based dashboards: If your dashboards use metrics and logs from Azure Monitor - for example, via Application Insights API, Azure Event Hubs, or Azure Storage - you might need to update them to reflect Azure Container Apps-specific metric names, namespaces, or log structures. Be sure to review and update your dashboards based on Azure Container Apps-specific metric mappings and data structures.
Carefully verify your dashboard configurations to ensure they remain accurate after the transition to Azure Container Apps.
Troubleshoot
Azure Container Apps doesn't provide an API to generate a heap dump or thread dump for Java applications. To create these dumps, you need to connect to the container app through the console. Then, use the jmap
or jstack
command to generate the dump files inside the container. After that, copy the generated files to your local machine for further analysis.
You can also use the jcmd
command to perform the same operation and start Java Flight Recorder (JFR) in a running application. For more information on how to access the container app via the console, see Connect to a container console in Azure Container Apps.
Known limitations
- Structured logs: Azure Container Apps doesn't support structured application logs. If your application logs follow the Azure Spring Apps schema, the full JSON string appears in the
Log_s
column ofContainerAppConsoleLogs_CL
. - Ingress logs: While Azure Spring Apps has built-in ingress access logs, Azure Container Apps doesn't. You need to implement access logging in your application code to capture this data.
- Azure Container Apps doesn't provide app lifecycle events.
- Azure Container Apps doesn't have built-in support for ingress metrics. You need to implement custom tracking in your applications.