Skip to main content Link Menu Expand (external link) Document Search Copy Copied

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

  1. 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   
    
  2. 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   
    
  3. 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, select Logs. You can inspect here the monitoring data in your app. If you double click ContainerAppConsoleLogs_CL or ‘ContainerAppSystemLogs_CL and press Run it will show you the data in this log table.

    Get logs for all apps

     ContainerAppConsoleLogs_CL
    

    alllogs

    Get logs for a specific app

     ContainerAppConsoleLogs_CL
    | where ContainerAppName_s == 'your-container-app-name'
    

    logs

    Get logs for Eureka Server

     ContainerAppSystemLogs_CL 
     | where ComponentType_s == "SpringCloudEureka"
    

    logs

    Get logs for Spring Cloud Config Server

     ContainerAppSystemLogs_CL 
     | where ComponentType_s == "SpringCloudConfig"
    

    logs

    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"
    

    logs