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
# Log storage and monitoring options in Azure Container Apps
14
15
15
-
Azure Container Apps gives you options for storing and viewing your application logs. Logging options are configured in your Container Apps environment where you select the log destination.
16
+
Azure Container Apps gives you options for storing and viewing your application logs. You can configure logging options at the Container Apps environment level. If you select Azure Monitor as your logs destination, you can configure diagnostic settings at both the environment level and the container app level.
16
17
17
18
Container Apps application logs consist of two different categories:
18
19
@@ -32,95 +33,160 @@ You can choose between these logs destinations:
32
33
33
34
When *Don't save logs* or the *Azure Monitor* destination is selected, the **Logs** menu item providing the Log Analytics query editor in the Azure portal is disabled.
34
35
35
-
## Configure options via the Azure portal
36
+
::: zone pivot="azure-portal"
36
37
37
-
Use these steps to configure the logging options for your Container Apps environment in the Azure portal:
38
+
## Configure logging options
39
+
40
+
Use these steps to configure the logging options for your environment in the Azure portal:
41
+
42
+
1. Browse to your Container Apps environment in the portal.
43
+
44
+
1. Select *Monitoring* > **Logging options**.
38
45
39
-
1. Go to the **Logging Options** on your Container Apps environment window in the portal.
40
-
:::image type="content" source="media/observability/log-opts-screenshot-log-analytics.png" alt-text="Screenshot of logs destinations.":::
41
46
1. You can choose from the following **Logs Destination** options:
42
-
-**Log Analytics**: With this option, you select a Log Analytics workspace to store your log data. Your logs can be viewed through Log Analytics queries. To learn more about Log Analytics, see [Azure Monitor Log Analytics](log-monitoring.md).
47
+
-**Azure Log Analytics**: With this option, you select a Log Analytics workspace to store your log data. Your logs can be viewed through Log Analytics queries. To learn more about Log Analytics, see [Azure Monitor Log Analytics](log-monitoring.md).
43
48
-**Azure Monitor**: Azure Monitor routes your logs to a destination. When you select this option, you must select **Diagnostic settings** to complete the configuration after you select **Save** on this page.
44
49
-**Don't save logs**: This option disables the storage of log data.
1. If you selected **Azure Monitor** as your logs destination, you must configure **Diagnostic settings**. The **Diagnostic settings** item appears below the **Logging options** menu item.
48
52
49
53
### Diagnostic settings
50
54
51
-
When you select **Azure Monitor** as your logs destination, you must configure the destination details. Select **Diagnostic settings** from the left side menu of the Container Apps Environment window in the portal. You might need to refresh the page for **Diagnostic settings** to appear.
55
+
If you selected **Azure Monitor** as your logs destination, you must also configure the diagnostic settings. You can configure the diagnostic settings at both the environment level and the container app level.
56
+
57
+
#### Configure diagnostic settings at the environment level
58
+
59
+
Use these steps to configure the diagnostic settings for your environment:
52
60
53
-
:::image type="content" source="media/observability/log-opts-diag-setting-menu-item.png" alt-text="Screenshot Diagnostic setting menu item.":::
61
+
1. Browse to your environment in the portal.
54
62
55
-
Destination details are saved as *diagnostic settings*. You can create up to five diagnostic settings for your container app environment. You can configure different log categories for each diagnostic setting. For example, create one diagnostic setting to send the system logs category to one destination, and another to send the container console logs category to another destination.
63
+
1. Select *Monitoring* > **Diagnostic settings**. If you've just set your environment's logs destination to **Azure Monitor**, you might need to refresh the page for this configuration item to appear.
64
+
65
+
Destination details are saved as *diagnostic settings*. You can create up to five diagnostic settings for your environment. You can configure different log categories for each diagnostic setting. For example, create one diagnostic setting to send the system logs category to one destination, and another to send the container console logs category to another destination.
56
66
57
67
To create a new *diagnostic setting*:
58
68
59
69
1. Select **Add diagnostic setting**.
60
-
:::image type="content" source="media/observability/diag-setting-new-diag-setting.png" alt-text="Screenshot Diagnostic setting Add new diagnostic setting.":::
-**Stream to an event hub**: Select from Azure event hubs.
71
81
-**Send to a partner solution**: Select from Azure partner solutions.
82
+
72
83
1. Select **Save**.
73
84
74
85
For more information about Diagnostic settings, see [Diagnostic settings in Azure Monitor](/azure/azure-monitor/essentials/diagnostic-settings).
75
86
76
-
## Configure options using the Azure CLI
87
+
#### Configure diagnostic settings at the container app level
88
+
89
+
Use these steps to configure the diagnostic settings for your container app:
90
+
91
+
1. Browse to your container app in the portal.
92
+
93
+
1. Select *Monitoring* > **Diagnostic settings**. If you've just set your container app environment's logs destination to **Azure Monitor**, you might need to refresh the page for this configuration item to appear.
94
+
95
+
1. Select **Add diagnostic setting**.
96
+
97
+
1. In **Diagnostic setting name**, enter a name for your diagnostic setting.
98
+
99
+
1. Under *Metrics*, select **AllMetrics**.
100
+
101
+
1. Select one or more **Destination details**:
102
+
-**Send to Log Analytics workspace**: Select from existing Log Analytics workspaces.
103
+
-**Archive to a storage account**: This option is deprecated.
104
+
-**Stream to an event hub**: Select from Azure event hubs.
105
+
-**Send to a partner solution**: Select from Azure partner solutions.
106
+
107
+
1. Select **Save**.
108
+
109
+
::: zone-end
110
+
111
+
::: zone pivot="azure-cli"
112
+
113
+
## Configure logging options
77
114
78
115
Configure logs destination for your Container Apps environment using the Azure CLI `az containerapp create` and `az containerapp update` commands with the `--logs-destination` argument.
79
116
80
-
The destination values are: `log-analytics`, `azure-monitor`, and `none`.
117
+
First, register the `Microsoft.Insights` namespace.
81
118
82
-
For example, to create a Container Apps environment using an existing Log Analytics workspace as the logs destination, you must provide the `--logs-destination` argument with the value `log-analytics` and the `--logs-destination-id` argument with the value of the Log Analytics workspace resource ID. You can get the resource ID from the Log Analytics workspace page in the Azure portal or from the ```az monitor log-analytics workspace show``` command.
119
+
```azurecli
120
+
az provider register --namespace Microsoft.Insights
121
+
```
122
+
123
+
### Send to a Log Analytics workspace
83
124
84
-
Replace \<PLACEHOLDERS\> with your values:
125
+
To create a Container Apps environment using an existing Log Analytics workspace as the logs destination, run the following command. Replace the `<PLACEHOLDERS>` with your values. You can get the Log Analytics workspace resource ID from the Log Analytics workspace page in the Azure portal, or from the [`az monitor log-analytics workspace show`](/cli/azure/monitor/log-analytics/workspace#az-monitor-log-analytics-workspace-show) command.
85
126
86
127
```azurecli
87
128
az containerapp env create \
88
129
--name <ENVIRONMENT_NAME> \
89
-
--resource-group <RESOURCE_GROUP> \
130
+
--resource-group <RESOURCE_GROUP_NAME> \
90
131
--logs-destination log-analytics \
91
-
--logs-workspace-id <WORKSPACE_ID>
132
+
--logs-workspace-id <LOG_ANALYTICS_WORKSPACE_ID>
92
133
```
93
134
94
-
To update an existing Container Apps environment to use Azure Monitor as the logs destination:
135
+
The `--logs-destination` argument accepts the values `log-analytics`, `azure-monitor`, and `none`.
95
136
96
-
Replace \<PLACEHOLDERS\> with your values:
137
+
### Send to Azure Monitor
138
+
139
+
To update an existing Container Apps environment to use Azure Monitor as the logs destination, run the following command. Replace the `<PLACEHOLDERS>` with your values:
97
140
98
141
```azurecli
99
142
az containerapp env update \
100
143
--name <ENVIRONMENT_NAME> \
101
-
--resource-group <RESOURCE_GROUP> \
144
+
--resource-group <RESOURCE_GROUP_NAME> \
102
145
--logs-destination azure-monitor
103
146
```
104
147
105
-
When `--logs-destination` is set to `azure-monitor`, create diagnostic settings to configure the destination details for the log categories with the `az monitor diagnostics-settings` command.
148
+
#### Configure diagnostic settings
106
149
107
-
To send app-level metrics to Log Analytics:
150
+
When `--logs-destination` is set to `azure-monitor`, you must create diagnostic settings to configure the destination details for the log categories with the `az monitor diagnostics-settings` command. You can configure these diagnostic settings at both the environment level and the container app level.
108
151
109
-
Replace \<PLACEHOLDERS\> with your values:
152
+
To create diagnostic settings at the environment level, run the following command. Replace the `<PLACEHOLDERS>` with your values. You can get the environment ID from the Environment page in the Azure portal, or from the [`az containerapp env show`](/cli/azure/containerapp/env#az-containerapp-env-show) command.
Ensure there are no spaces in the JSON values provided to the `--logs` and `--metrics` parameters.
164
+
165
+
For the `--logs` parameter, you can specify `category` or `categoryGroup`, but not both at once. For `categoryGroup`, the available values are `audit` and `allLogs`. For `category`, the available values are `ContainerAppConsoleLogs` and `ContainerAppSystemLogs`.
166
+
167
+
For the `--metrics` parameter, the only available category is `AllMetrics`.
168
+
169
+
For more information see [LogSettings](/rest/api/monitor/diagnostic-settings/create-or-update#logsettings) and [MetricSettings](/rest/api/monitor/diagnostic-settings/create-or-update#metricsettings).
170
+
171
+
To create diagnostic settings at the container app level, run the following command. Replace the `<PLACEHOLDERS>` with your values. You can get the container app ID from the Azure portal, or from the [`az containerapp show`](/cli/azure/containerapp#az-containerapp-show) command.
172
+
173
+
When creating diagnostic settings at the container app level, the `--logs` parameter is not supported, and for the `--metrics` parameter, the only available category is `AllMetrics`.
For more information about Azure Monitor diagnostic settings commands, see [az monitor diagnostic-settings](/cli/azure/monitor/diagnostic-settings). Container Apps log categories are `ContainerAppConsoleLogs` and `ContainerAppSystemLogs`.
183
+
For more information about Azure Monitor diagnostic settings commands, see [az monitor diagnostic-settings](/cli/azure/monitor/diagnostic-settings).
184
+
185
+
::: zone-end
120
186
121
187
## Limitations
122
188
123
-
The following limitations exist as you set up your log options.
189
+
The following limitations apply as you set up your log options.
124
190
125
191
-**Private link**: Sending logs directly to a Log Analytics Workspace through Private Link isn't supported. However, you can use Azure Monitor and send your logs to the same Log Analytics Workspace. This indirection is required to prevent system log data loss.
0 commit comments