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
Code interpreter sessions don't support logging directly. The application that's interacting with the sessions can log requests to the session pool management API and its responses.
308
+
Code interpreter sessions emit application logs to Log Analytics, but don't emit platform logs. If you need request/response tracing, capture it in the application that calls the session pool management API (for example, log request IDs, inputs, and responses at your app boundary).
| Application logs |`AppEnvSessionConsoleLogs`| Standard output (`stdout`) and standard error (`stderr`) emitted by code running in the session. Logs appear after a session is invoked. |
315
+
| Platform logs | Not applicable | Session lifecycle and pool event logs aren't emitted for code interpreter session pools. |
316
+
317
+
If logs are sent directly to Log Analytics, the table uses the _CL suffix (for example, `AppEnvSessionConsoleLogs_CL`). When logs are routed through Azure Monitor diagnostic settings, the table name doesn't include the _CL suffix.
318
+
319
+
## Metrics
320
+
321
+
Code interpreter usage and execution metrics are returned as HTTP response headers for the Execute Code API. These metrics aren't written to Log Analytics.
322
+
323
+
### View metrics
324
+
325
+
1. Call the Execute Code API (`code/execute`).
326
+
2. Inspect the HTTP response headers for usage and execution metrics.
327
+
328
+
For details about the Execute Code API and endpoints, see [Run code in a session](#run-code-in-a-session) and [Management API endpoints](#management-api-endpoints).
309
329
310
330
## Billing
311
331
312
332
Code interpreter sessions are billed based on the duration of each session. For more information, see [Billing](billing.md#dynamic-sessions).
313
333
314
-
## Next step
334
+
## Next steps
315
335
316
336
> [!div class="nextstepaction"]
317
337
> [Use code interpreter sessions with LangChain](./sessions-tutorial-langchain.md)
Copy file name to clipboardExpand all lines: articles/container-apps/sessions-custom-container.md
+102Lines changed: 102 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,108 @@ To use custom container sessions, you first create a session pool with a custom
31
31
32
32
When your application requests a session, an instance is instantly allocated from the pool. The session remains active until it enters an idle state, which is then automatically stopped and destroyed.
33
33
34
+
## Logging
35
+
36
+
Custom container session pools integrate with Azure Monitor and Log Analytics. Application logs are captured only if your container writes output to `stdout` or `stderr`, so make sure your app emits logs to the console.
37
+
38
+
### Prerequisites
39
+
40
+
- An Azure Container Apps environment with a custom container session pool
41
+
- A Log Analytics workspace (or create one during setup)
42
+
43
+
### Configure logging
44
+
45
+
#### Step 1: Enable Azure Monitor logging
46
+
47
+
1. Navigate to your **Container Apps Environment** in the Azure portal.
48
+
2. Under **Monitoring**, select **Logging options**.
49
+
3. Set the logs destination to **Azure Monitor**.
50
+
51
+
#### Step 2: Configure diagnostic settings
52
+
53
+
1. In your Container Apps Environment, navigate to **Diagnostic settings** under **Monitoring**.
54
+
2. Select **+ Add diagnostic setting**.
55
+
3. Provide a name for your diagnostic setting.
56
+
4. Under **Logs**, select the session-related log categories you want to capture.
57
+
5. Under **Destination details**, select **Send to Log Analytics workspace**.
58
+
6. Choose your Log Analytics workspace (or create a new one).
| Application logs |`AppEnvSessionConsoleLogs`| Standard output (`stdout`) and standard error (`stderr`) emitted by the containerized application. |
66
+
| Platform logs |`AppEnvSessionLifecycleLogs`, `AppEnvSessionPoolEvents`| Platform-generated events related to session pool allocation, lifecycle, and operational state. |
67
+
68
+
If logs are sent directly to Log Analytics, the tables use the _CL suffix (for example, `AppEnvSessionConsoleLogs_CL`). When logs are routed through Azure Monitor diagnostic settings, the table names don't include the _CL suffix.
69
+
70
+
### View session logs
71
+
72
+
Once diagnostic settings are configured, logs are sent to your Log Analytics workspace.
73
+
74
+
#### Query logs in Log Analytics
75
+
76
+
1. Navigate to your **Log Analytics workspace** in the Azure portal.
77
+
2. Select **Logs** under **General**.
78
+
3. Use [Kusto Query Language (KQL)](/azure/data-explorer/kusto/query/) to query session logs.
79
+
80
+
#### Example queries
81
+
82
+
**View recent console logs from sessions:**
83
+
84
+
```kusto
85
+
AppEnvSessionConsoleLogs
86
+
| where TimeGenerated > ago(1h)
87
+
| order by TimeGenerated desc
88
+
| take 100
89
+
```
90
+
91
+
**View session lifecycle events:**
92
+
93
+
```kusto
94
+
AppEnvSessionLifecycleLogs
95
+
| where TimeGenerated > ago(1h)
96
+
| order by TimeGenerated desc
97
+
```
98
+
99
+
**View session pool events:**
100
+
101
+
```kusto
102
+
AppEnvSessionPoolEvents
103
+
| where TimeGenerated > ago(1h)
104
+
| order by TimeGenerated desc
105
+
```
106
+
107
+
## Metrics
108
+
109
+
Azure Container Apps emits Azure Monitor metrics for custom container session pools. Use these metrics to track pool capacity and activity over time.
110
+
111
+
### Supported metrics
112
+
113
+
For the complete list, see [Supported metrics - Microsoft.App/sessionpools - Azure Monitor](/azure/azure-monitor/reference/supported-metrics/microsoft-app-sessionpools-metrics).
114
+
115
+
| Metric | Name in REST API | Unit | Aggregation | Dimensions | Time Grains | DS Export |
116
+
| --- | --- | --- | --- | --- | --- | --- |
117
+
|**Executing Sessions Count**<br>Number of executing session pods in the session pool |`PoolExecutingPodCount`| Count | Total (Sum), Average, Maximum, Minimum |`poolName`| PT1M | Yes |
118
+
|**Creating Sessions Count**<br>Number of creating session pods in the session pool |`PoolPendingPodCount`| Count | Total (Sum), Average, Maximum, Minimum |`poolName`| PT1M | Yes |
119
+
|**Ready Sessions Count**<br>Number of ready session pods in the session pool |`PoolReadyPodCount`| Count | Total (Sum), Average, Maximum, Minimum |`poolName`| PT1M | Yes |
120
+
121
+
### View session metrics
122
+
123
+
#### Option 1: Azure Monitor Metrics
124
+
125
+
1. Open the [Azure Monitor Metrics page](https://ms.portal.azure.com/#view/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/~/metrics).
126
+
2. Select your custom container session pool as the scope.
127
+
3. Choose a metric and aggregation to view.
128
+
129
+
#### Option 2: Container Apps environment metrics
130
+
131
+
1. In the Azure portal, open your Container Apps environment.
132
+
2. Select **Metrics**.
133
+
3. Use **Scope** to select your custom container session pool.
134
+
4. Choose a metric and aggregation to view.
135
+
34
136
## Related content
35
137
36
138
*[Serverless code interpreter sessions in Azure Container Apps](sessions-code-interpreter.md)
Copy file name to clipboardExpand all lines: articles/container-apps/sessions-usage.md
+8-38Lines changed: 8 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -310,52 +310,22 @@ This template contains the following settings for managed identity:
310
310
311
311
## Logging
312
312
313
-
Azure Container Apps dynamic sessions integrate with Azure Monitor and Log Analytics to collect logs emitted during session execution. Logging behavior is consistent across code interpreter and custom container session pools, and is distinct from metrics returned via API response headers.
314
-
315
-
### Log destinations
316
-
317
-
When Log Analytics is selected as the logging destination for the Container Apps environment, session logs are written to the configured Log Analytics workspace and can be queried using [Kusto Query Language (KQL)](/azure/data-explorer/kusto/query/).
313
+
Azure Container Apps dynamic sessions integrate with Azure Monitor and Log Analytics to collect logs emitted during session execution. The configuration steps are the same for code interpreter and custom container session pools, but the available log categories differ by session type. Metrics returned via API response headers aren't written to Log Analytics.
318
314
319
315
### Available Log Analytics tables
320
316
321
-
The following Log Analytics tables are created for session logs when logs are emitted. For a full list of supported categories on the environment resource (`Microsoft.App/managedEnvironments`), see [Supported logs for Microsoft.App/managedEnvironments](/azure/azure-monitor/reference/supported-logs/microsoft-app-managedenvironments-logs).
317
+
The following Log Analytics tables are created when logs are first emitted. For a full list of supported categories on the environment resource (`Microsoft.App/managedEnvironments`), see [Supported logs for Microsoft.App/managedEnvironments](/azure/azure-monitor/reference/supported-logs/microsoft-app-managedenvironments-logs).
| Code interpreter sessions (platform-managed) | Application logs |`AppEnvSessionConsoleLogs_CL`| Standard output (`stdout`) and standard error (`stderr`) emitted by code running in the session. Logs appear after a session is invoked. |
326
-
| Code interpreter sessions (platform-managed) | Platform logs | Not applicable | Session lifecycle and pool event logs aren't emitted for code interpreter session pools. |
327
-
| Custom container sessions | Application logs |`AppEnvSessionConsoleLogs_CL`| Standard output (`stdout`) and standard error (`stderr`) emitted by the containerized application. Azure Container Apps does not generate application logs for custom containers; you must emit logs from your container. |
328
-
| Custom container sessions | Platform logs |`AppEnvSessionLifecycleLogs_CL`, `AppEnvSessionPoolEventLogs_CL`| Platform-generated events related to session pool allocation, lifecycle, and operational state. |
329
-
330
-
These tables are created when logs are first emitted. If no sessions have been invoked, the tables might not yet appear in the workspace.
331
-
332
-
Table names include the _CL suffix when logs are sent directly to Log Analytics. When logs are routed through Azure Monitor diagnostic settings, the table names don't include the _CL suffix.
Output written to `stdout` or `stderr` is captured in the `AppEnvSessionConsoleLogs_CL` table.
340
-
341
-
-**Platform logs**
342
-
Session lifecycle and pool event logs aren't emitted for code interpreter session pools.
343
-
344
-
-**Metrics**
345
-
Usage and execution metrics are returned as HTTP response headers for the Execute Code API only. These metrics aren't written to Log Analytics.
346
-
347
-
#### Custom container sessions
348
-
349
-
-**Application logs**
350
-
Logs are captured only if the containerized application writes output to `stdout` or `stderr`.
351
-
These logs appear in the `AppEnvSessionConsoleLogs_CL` table.
352
-
353
-
-**Platform logs**
354
-
Session pool allocation and lifecycle events are captured in `AppEnvSessionLifecycleLogs_CL` and `AppEnvSessionPoolEventLogs_CL`.
321
+
| Code interpreter sessions (platform-managed) | Application logs |`AppEnvSessionConsoleLogs`| Standard output (`stdout`) and standard error (`stderr`) emitted by code running in the session. Logs appear after a session is invoked. |
322
+
|| Platform logs | Not applicable | Session lifecycle and pool event logs aren't emitted for code interpreter session pools. |
323
+
| Custom container sessions | Application logs |`AppEnvSessionConsoleLogs`| Standard output (`stdout`) and standard error (`stderr`) emitted by the containerized application. Azure Container Apps doesn't generate application logs for custom containers; you must emit logs from your container. |
324
+
|| Platform logs |`AppEnvSessionLifecycleLogs`, `AppEnvSessionPoolEvents`| Platform-generated events related to session pool allocation, lifecycle, and operational state. |
355
325
356
-
-**Customer responsibility**
357
-
Azure Container Apps doesn't generate application-level logs for custom containers. You must emit logs from within your containerized applications.
326
+
If logs are sent directly to Log Analytics, the tables use the _CL suffix (for example, `AppEnvSessionConsoleLogs_CL`). When logs are routed through Azure Monitor diagnostic settings, the table names don't include the _CL suffix.
358
327
328
+
See also: For logging and metrics details, see [Custom container sessions](./sessions-custom-container.md#logging) and [Code interpreter sessions](./sessions-code-interpreter.md#logging).
0 commit comments