title | description | services | author | ms.service | ms.topic | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|
Monitor an app in Azure Container Apps |
Learn how applications are monitored and logged in Azure Container Apps. |
container-apps |
craigshoemaker |
container-apps |
conceptual |
11/02/2021 |
cshoe |
ignite-fall-2021, event-tier1-build-2022 |
Azure Container Apps gathers a broad set of data about your container app and stores it using Log Analytics. This article describes the available logs, and how to write and view logs.
When you write to the Standard output (stdout) or standard error (stderr) streams, the Container Apps logging agents write logs for each message.
As a message is logged, the following information is gathered in the log table:
Property | Remarks |
---|---|
RevisionName |
|
ContainerAppName |
|
ContainerGroupID |
|
ContainerGroupName |
|
ContainerImage |
|
ContainerID |
The container's unique identifier. You can use this value to help identify container crashes. |
Stream |
Shows whether stdout or stderr is used for logging. |
EnvironmentName |
You can log a single text string or line of serialized JSON data. Information is displayed differently depending on what type of data you log.
Data type | Description |
---|---|
A single line of text | Text appears in the Log_s column. |
Serialized JSON | Data is parsed by the logging agent and displayed in columns that match the JSON object property names. |
Data logged via a container app are stored in the ContainerAppConsoleLogs_CL
custom table in the Log Analytics workspace. You can view logs through the Azure portal or with the CLI.
Set the name of your resource group and Log Analytics workspace, and then retrieve the LOG_ANALYTICS_WORKSPACE_CLIENT_ID
with the following commands.
RESOURCE_GROUP="my-containerapps"
LOG_ANALYTICS_WORKSPACE="containerapps-logs"
LOG_ANALYTICS_WORKSPACE_CLIENT_ID=`az monitor log-analytics workspace show --query customerId -g $RESOURCE_GROUP -n $LOG_ANALYTICS_WORKSPACE --out tsv`
$RESOURCE_GROUP="my-containerapps"
$LOG_ANALYTICS_WORKSPACE="containerapps-logs"
$LOG_ANALYTICS_WORKSPACE_CLIENT_ID=az monitor log-analytics workspace show --query customerId -g $RESOURCE_GROUP -n $LOG_ANALYTICS_WORKSPACE --out tsv
Use the following CLI command to view logs on the command line.
az monitor log-analytics query \
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'my-container-app' | project ContainerAppName_s, Log_s, TimeGenerated | take 3" \
--out table
az monitor log-analytics query `
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID `
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'my-container-app' | project ContainerAppName_s, Log_s, TimeGenerated | take 3" `
--out table
The following output demonstrates the type of response to expect from the CLI command.
ContainerAppName_s Log_s TableName TimeGenerated
-------------------- -------------------- ------------- ------------------------
my-container-app listening on port 80 PrimaryResult 2021-10-23T02:09:00.168Z
my-container-app listening on port 80 PrimaryResult 2021-10-23T02:11:36.197Z
my-container-app listening on port 80 PrimaryResult 2021-10-23T02:11:43.171Z
[!div class="nextstepaction"] Manage secrets