Skip to content

Commit 5049bbb

Browse files
authored
Merge pull request #203674 from cebundy/add-la-table-observability
Add system logs to observability doc
2 parents 940dd6b + eb29028 commit 5049bbb

File tree

2 files changed

+84
-24
lines changed

2 files changed

+84
-24
lines changed
-8.95 KB
Loading

articles/container-apps/observability.md

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: cebundy
66
ms.service: container-apps
77
ms.custom: event-tier1-build-2022
88
ms.topic: conceptual
9-
ms.date: 05/02/2022
9+
ms.date: 07/05/2022
1010
ms.author: v-bcatherine
1111
---
1212

@@ -16,11 +16,11 @@ Azure Container Apps provides several built-in observability features that give
1616

1717
These features include:
1818

19-
- Log streaming
20-
- Container console
21-
- Azure Monitor metrics
22-
- Azure Monitor Log Analytics
23-
- Azure Monitor alerts
19+
- [Log streaming](#log-streaming)
20+
- [Container console](#container-console)
21+
- [Azure Monitor metrics](#azure-monitor-metrics)
22+
- [Azure Monitor Log Analytics](#azure-monitor-log-analytics)
23+
- [Azure Monitor alerts](#azure-monitor-alerts)
2424

2525
>[!NOTE]
2626
> While not a built-in feature, [Azure Monitor's Application Insights](../azure-monitor/app/app-insights-overview.md) is a powerful tool to monitor your web and background applications.
@@ -250,55 +250,115 @@ You can add more scopes to view metrics across multiple container apps.
250250

251251
## Azure Monitor Log Analytics
252252

253+
Azure Container Apps is integrated with Azure Monitor Log Analytics to monitor and analyze your container app's logs. Each Container Apps environment includes a Log Analytics workspace that provides a common place to store the system and application log data from all container apps running in the environment.
254+
255+
Log entries are accessible by querying Log Analytics tables through the Azure portal or a command shell using the [Azure CLI](/cli/azure/monitor/log-analytics).
256+
257+
<!--
253258
Azure Monitor collects application logs and stores them in a Log Analytics workspace. Each Container Apps environment includes a Log Analytics workspace that provides a common place to store the application log data from all containers running in the environment.
259+
-->
260+
261+
There are two types of logs for Container Apps.
262+
263+
1. Console logs, which are emitted by your app.
264+
1. System logs, which are emitted by the Container Apps service.
265+
266+
267+
### Container Apps System Logs
254268

255-
Application logs consist of messages written to each container's `stdout` and `stderr`. Additionally, if your container app is using Dapr, log entries from the Dapr sidecar are also collected.
269+
The Container Apps service provides system log messages at the container app level. System logs emits the following messages:
256270

257-
Azure Monitor stores Container Apps log data in the `ContainerAppConsoleLogs_CL` table. Create queries using this table to view your container app log data.
271+
| Source | Type | Message |
272+
|---------|------|---------|
273+
| Dapr | info | Successfully created dapr component \<component-name\> with scope \<dapr-component-scope\> |
274+
| Dapr | info | Successfully updated dapr component \<component-name\> with scope \<component-type\> |
275+
| Dapr | error | Error creating dapr component \<component-name\> |
276+
| Volume Mounts | info | Successfully mounted volume \<volume-name\> for revision \<revision-scope\> |
277+
| Volume Mounts | error | Error mounting volume \<volume-name\> |
278+
| Domain Binding | info | Successfully bound Domain \<domain\> to the container app \<container app name\> |
279+
| Authentication | info | Auth enabled on app. Creating authentication config |
280+
| Authentication | info | Auth config created successfully |
281+
| Traffic weight | info | Setting a traffic weight of \<percentage>% for revision \<revision-name\\> |
282+
| Revision Provisioning | info | Creating a new revision: \<revision-name\> |
283+
| Revision Provisioning | info | Successfully provisioned revision \<name\> |
284+
| Revision Provisioning | info| Deactivating Old revisions since 'ActiveRevisionsMode=Single' |
285+
| Revision Provisioning | error | Error provisioning revision \<revision-name>. ErrorCode: \<[ErrImagePull]\|[Timeout]\|[ContainerCrashing]\> |
258286

259-
You can create and run queries using Log Analytics in the Azure portal or run queries using Azure CLI commands.
287+
The system log data is accessible by querying the `ContainerAppSystemlogs_CL` table. The most used Container Apps specific columns in the table are:
260288

261-
The most used columns in ContainerAppConsoleLogs_CL include:
289+
| Column | Description |
290+
|---|---|
291+
| `ContainerAppName_s` | Container app name |
292+
| `EnvironmentName_s` | Container Apps environment name |
293+
| `Log_s` | Log message |
294+
| `RevisionName_s` | Revision name |
295+
296+
### Container Apps Console Logs
297+
298+
Console logs originate from the `stderr` and `stdout` messages from the containers in your container app and Dapr sidecars. You can view console logs by querying the `ContainerAppConsolelogs_CL` table.
299+
300+
> [!TIP]
301+
> Instrumenting your code with well-defined log messages can help you to understand how your code is performing and to debug issues. To learn more about best practices refer to [Design for operations](/azure/architecture/guide/design-principles/design-for-operations).
302+
303+
The most commonly used Container Apps specific columns in ContainerAppConsoleLogs_CL include:
262304

263305
|Column |Description |
264306
|---------|---------|
265-
| `ContainerAppName_s` | container app name |
266-
| `ContainerGroupName_g` | replica name |
267-
| `ContainerId` | container identifier |
268-
| `ContainerImage_s` | container image name |
307+
| `ContainerAppName_s` | Container app name |
308+
| `ContainerGroupName_g` | Replica name |
309+
| `ContainerId_s` | Container identifier |
310+
| `ContainerImage_s` | Container image name |
269311
| `EnvironmentName_s` | Container Apps environment name |
270-
| `Message` | log message |
271-
| `RevisionName_s` | revision name |
312+
| `Log_s` | Log message |
313+
| `RevisionName_s` | Revision name |
272314

273315
### Use Log Analytics to query logs
274316

275-
Log Analytics is a tool in the Azure portal that you can use to view and analyze log data. Using Log Analytics, you can write simple or advanced queries and then sort, filter, and visualize the results in charts to spot trends and identify issues. You can work interactively with the query results or use them with other features such as alerts, dashboards, and workbooks.
317+
Log Analytics is a tool in the Azure portal that you can use to view and analyze log data. Using Log Analytics, you can write Kusto queries and then sort, filter, and visualize the results in charts to spot trends and identify issues. You can work interactively with the query results or use them with other features such as alerts, dashboards, and workbooks.
276318

277319
Start Log Analytics from **Logs** in the sidebar menu on your container app page. You can also start Log Analytics from **Monitor>Logs**.
278320

279-
You can query the logs using the columns listed in the **CustomLogs > ContainerAppConsoleLogs_CL** table in the **Tables** tab.
321+
You can query the logs using the tables listed in the **CustomLogs** category **Tables** tab. The tables in this category are the `ContainerAppSystemlogs_CL` and `ContainerAppConsolelogs_CL` tables.
280322

281-
:::image type="content" source="media/observability/log-analytics-query-page.png" alt-text="Screenshot of the Log Analytics query editor.":::
323+
:::image type="content" source="media/observability/log-analytics-query-page.png" alt-text="Screenshot of the Log Analytics custom log tables.":::
282324

283-
Below is a simple query that displays log entries for the container app named *album-api*.
325+
Below is a Kusto query that displays console log entries for the container app named *album-api*.
284326

285327
```kusto
286328
ContainerAppConsoleLogs_CL
287329
| where ContainerAppName_s == 'album-api'
288-
| project Time=TimeGenerated, AppName=ContainerAppName_s, Revision=RevisionName_s, Container=ContainerName_s, Message=Message
330+
| project Time=TimeGenerated, AppName=ContainerAppName_s, Revision=RevisionName_s, Container=ContainerName_s, Message=Log_s
331+
| take 100
332+
```
333+
334+
Below is a Kusto query that displays system log entries for the container app named *album-api*.
335+
336+
```kusto
337+
ContainerAppSystemLogs_CL
338+
| where ContainerAppName_s == 'album-api'
339+
| project Time=TimeGenerated, EnvName=EnvironmentName_s, AppName=ContainerAppName_s, Revision=RevisionName_s, Message=Log_s
289340
| take 100
290341
```
291342

292343
For more information regarding Log Analytics and log queries, see the [Log Analytics tutorial](../azure-monitor/logs/log-analytics-tutorial.md).
293344

294-
### Query logs via the Azure CLI and PowerShell
345+
### Query logs via the Azure CLI
295346

296347
Container Apps logs can be queried using the [Azure CLI](/cli/azure/monitor/log-analytics).
297348

298-
Here's an example Azure CLI query to output a table containing five log records with the container app name "album-api". The table columns are specified by the parameters after the project operator. The $WORKSPACE_CUSTOMER_ID variable contains the GUID of the Log Analytics workspace.
349+
These example Azure CLI queries output a table containing log records for the container app name **album-api**. The table columns are specified by the parameters after the `project` operator. The `$WORKSPACE_CUSTOMER_ID` variable contains the GUID of the Log Analytics workspace.
350+
351+
352+
This example queries the `ContainerAppConsoleLogs_CL` table:
353+
354+
```azurecli
355+
az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'album-api' | project Time=TimeGenerated, AppName=ContainerAppName_s, Revision=RevisionName_s, Container=ContainerName_s, Message=Log_s, LogLevel_s | take 5" --out table
356+
```
357+
358+
This example queries the `ContainerAppSystemLogs_CL` table:
299359

300360
```azurecli
301-
az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'album-api' | project Time=TimeGenerated, AppName=ContainerAppName_s, Revision=RevisionName_s, Container=ContainerName_s, Message=Message, LogLevel_s | take 5" --out table
361+
az monitor log-analytics query --workspace $WORKSPACE_CUSTOMER_ID --analytics-query "ContainerAppSystemLogs_CL | where ContainerAppName_s == 'album-api' | project Time=TimeGenerated, AppName=ContainerAppName_s, Revision=RevisionName_s, Message=Log_s, LogLevel_s | take 5" --out table
302362
```
303363

304364
For more information about using Azure CLI to view container app logs, see [Viewing Logs](monitor.md#viewing-logs).

0 commit comments

Comments
 (0)