Configure Azure Container Apps environment monitoring
Point in time info of your application is nice, however, it is also beneficial to have overall monitoring data available. For this you can enable logs on your Azure Container Apps environment. Container Apps application logs consist of two different categories:
- Container console output (stdout/stderr) messages.
- System logs generated by Azure Container Apps.
- Spring App console logs.
Enable logging on your Azure Container Apps environment. You can follow the below guidance to do so.
Step by step guidance
-
In your bash shell, create a Log Analytics workspace.
WORKSPACE=la-$APPNAME-$UNIQUEID az monitor log-analytics workspace create \ --resource-group $RESOURCE_GROUP \ --workspace-name $WORKSPACE
-
Enable logging on your Azure Container Apps environment.
WORKSPACECID=$(az monitor log-analytics workspace show -n $WORKSPACE -g $RESOURCE_GROUP --query customerId -o tsv) WORKSPACEKEY=$(az monitor log-analytics workspace get-shared-keys -n $WORKSPACE -g $RESOURCE_GROUP --query primarySharedKey -o tsv) az containerapp env update \ --name $ACA_ENVIRONMENT \ --resource-group $RESOURCE_GROUP \ --logs-destination log-analytics \ --logs-workspace-id $WORKSPACECID \ --logs-workspace-key $WORKSPACEKEY
-
To verify that monitoring data is available in your Log Analytics workspace, in your browser, navigate to your ACA instance in the Azure Portal. Under
Monitoring
, selectLogs
. You can inspect here the monitoring data in your app. If you double clickContainerAppConsoleLogs_CL
or ‘ContainerAppSystemLogs_CL and pressRun
it will show you the data in this log table.Get logs for all apps
ContainerAppConsoleLogs_CL
Get logs for a specific app
ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'your-container-app-name'
Get logs for Eureka Server
ContainerAppSystemLogs_CL | where ComponentType_s == "SpringCloudEureka"
Get logs for Spring Cloud Config Server
ContainerAppSystemLogs_CL | where ComponentType_s == "SpringCloudConfig"
Type and run the following Kusto query to see errors and exceptions thrown by each app:
ContainerAppConsoleLogs_CL | where Log_s contains "error" or Log_s contains "exception"