You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 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.
250
250
251
251
## Azure Monitor Log Analytics
252
252
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
+
<!--
253
258
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
254
268
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:
256
270
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\>|
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:
260
288
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:
262
304
263
305
|Column |Description |
264
306
|---------|---------|
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 |
269
311
|`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 |
272
314
273
315
### Use Log Analytics to query logs
274
316
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.
276
318
277
319
Start Log Analytics from **Logs** in the sidebar menu on your container app page. You can also start Log Analytics from **Monitor>Logs**.
278
320
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.
280
322
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.":::
282
324
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*.
For more information regarding Log Analytics and log queries, see the [Log Analytics tutorial](../azure-monitor/logs/log-analytics-tutorial.md).
293
344
294
-
### Query logs via the Azure CLI and PowerShell
345
+
### Query logs via the Azure CLI
295
346
296
347
Container Apps logs can be queried using the [Azure CLI](/cli/azure/monitor/log-analytics).
297
348
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:
299
359
300
360
```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
302
362
```
303
363
304
364
For more information about using Azure CLI to view container app logs, see [Viewing Logs](monitor.md#viewing-logs).
0 commit comments