Skip to content

Commit 8964bf4

Browse files
Merge pull request #291244 from craigshoemaker/aca/jw/otel-updates
[Container Apps] Update: Otel agents
2 parents eabc84d + 2c54111 commit 8964bf4

File tree

1 file changed

+77
-21
lines changed

1 file changed

+77
-21
lines changed

articles/container-apps/opentelemetry-agents.md

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn to record and query data collected using OpenTelemetry in Azu
44
services: container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
7-
ms.date: 11/01/2024
7+
ms.date: 12/02/2024
88
ms.author: cshoe
99
ms.topic: how-to
1010
---
@@ -25,10 +25,9 @@ OpenTelemetry agents live within your container app environment. You configure a
2525

2626
Each endpoint type (Azure Monitor Application Insights, DataDog, and OTLP) has specific configuration requirements.
2727

28-
2928
## Prerequisites
3029

31-
Enabling the managed OpenTelemetry agent to your environment doesn't automatically mean the agent collects data. Agents only send data based on your configuration settings and instrumenting your code correctly.
30+
Enabling the managed OpenTelemetry agent to your environment doesn't automatically mean the agent collects data. Agents only send data based on your configuration settings and instrumenting your code correctly.
3231

3332
### Configure source code
3433

@@ -56,6 +55,10 @@ The following table shows you what type of data you can send to each destination
5655

5756
The only configuration detail required from Application Insights is the connection string. Once you have the connection string, you can configure the agent via your container app's ARM template or with Azure CLI commands.
5857

58+
The connection string contains an instrumentation key, which is a unique identifier used to associate telemetry to a specific Application Insights resource. Instrumentation keys aren't security tokens or security keys, and aren't considered secrets.
59+
60+
If you want to protect your Application Insights resource from misuse, see [Microsoft Entra authentication for Application Insights](/azure/azure-monitor/app/azure-ad-authentication#microsoft-entra-authentication-for-application-insights).
61+
5962
# [ARM template](#tab/arm)
6063

6164
Before you deploy this template, replace placeholders surrounded by `<>` with your values.
@@ -65,7 +68,7 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
6568
...
6669
"properties": {
6770
"appInsightsConfiguration ": {
68-
"connectionString": "<YOUR_APP_INSIGHTS_CONNECTION_STRING>"
71+
"connectionString": "<APP_INSIGHTS_CONNECTION_STRING>"
6972
}
7073
"openTelemetryConfiguration": {
7174
...
@@ -86,14 +89,15 @@ Before you run this command, replace placeholders surrounded by `<>` with your v
8689

8790
```azurecli
8891
az containerapp env telemetry app-insights set \
89-
--resource-group <YOUR_RESOURCE_GROUP_NAME> \
90-
--name <YOUR_ENVIRONMENT_NAME> \
91-
--connection-string <YOUR_APP_INSIGHTS_CONNECTION_STRING> \
92+
--resource-group <RESOURCE_GROUP_NAME> \
93+
--name <ENVIRONMENT_NAME> \
94+
--connection-string <APP_INSIGHTS_CONNECTION_STRING> \
9295
--enable-open-telemetry-traces true \
9396
--enable-open-telemetry-logs true
9497
```
98+
9599
>[!NOTE]
96-
> Due to the sensitivity of the connection-string, you will not be able to see the detail values of the connection string when the command returns. The system will display it as null.
100+
> Due to the sensitivity of the connection-string, you will not be able to see the detail values of the connection string when the command returns. The system will display it as null.
97101
98102
---
99103

@@ -108,13 +112,51 @@ The Datadog agent configuration requires a value for `site` and `key` from your
108112

109113
Once you have these configuration details, you can configure the agent via your container app's ARM template or with Azure CLI commands.
110114

115+
Avoid specifying the value of a secret, such as your Datadog API key, directly in a production environment. Instead, use a reference to a secret stored in Azure Key Vault.
116+
117+
You must enable the key vault for template deployment. To do this, create the key vault with the `enabledForTemplateDeployment` property enabled, or run the following Azure CLI command, replacing the `<KEY_VAULT_NAME>` with your value:
118+
119+
```azurecli
120+
az keyvault update --name <KEY_VAULT_NAME> --enabled-for-template-deployment true
121+
```
122+
123+
For more information, see:
124+
- [Use Azure Key Vault to pass secure parameter value during deployment](/azure/azure-resource-manager/templates/key-vault-parameter)
125+
- [Tutorial: Integrate Azure Key Vault in your ARM template deployment](/azure/azure-resource-manager/templates/template-tutorial-use-key-vault)
126+
111127
# [ARM template](#tab/arm)
112128

113-
Before you deploy this template, replace placeholders surrounded by `<>` with your values.
129+
Create a [parameter file](/azure/azure-resource-manager/templates/parameter-files) to retrieve your Datadog API key from an Azure Key Vault.
130+
131+
Before you deploy the following files, replace placeholders surrounded by `<>` with your values.
132+
133+
```json
134+
{
135+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
136+
"contentVersion": "1.0.0.0",
137+
"parameters": {
138+
"datadogapikey": {
139+
"reference": {
140+
"keyVault": {
141+
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>/providers/Microsoft.KeyVault/vaults/<KEY_VAULT_NAME>"
142+
},
143+
"secretName": "<KEY_VAULT_SECRET_NAME>"
144+
}
145+
}
146+
}
147+
}
148+
```
149+
150+
You can now reference the `datadogapikey` parameter in your ARM Template.
114151

115152
```json
116153
{
117154
...
155+
"parameters": {
156+
"datadogapikey": {
157+
"type": "securestring"
158+
}
159+
},
118160
"properties": {
119161
...
120162
"openTelemetryConfiguration": {
@@ -137,20 +179,29 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
137179
}
138180
```
139181

182+
To deploy the resource, run the following Azure CLI command, replacing the placeholders surrounded by `<>` with your values.
183+
184+
```azurecli
185+
az deployment group create \
186+
--resource-group <RESOURCE_GROUP> \
187+
--template-file <ARM_TEMPLATE_FILE> \
188+
--parameters <PARAMETER_FILE>
189+
```
140190

141191
# [Azure CLI](#tab/azure-cli)
142192

143193
Before you run this command, replace placeholders surrounded by `<>` with your values.
144194

145195
```azurecli
146196
az containerapp env telemetry data-dog set \
147-
--resource-group <YOUR_RESOURCE_GROUP_NAME> \
148-
--name <YOUR_ENVIRONMENT_NAME> \
149-
--site "<YOUR_DATADOG_SUBDOMAIN>.datadoghq.com" \
150-
--key <YOUR_DATADOG_KEY> \
197+
--resource-group <RESOURCE_GROUP_NAME> \
198+
--name <ENVIRONMENT_NAME> \
199+
--site "<DATADOG_SUBDOMAIN>.datadoghq.com" \
200+
--key <DATADOG_KEY> \
151201
--enable-open-telemetry-traces true \
152202
--enable-open-telemetry-metrics true
153203
```
204+
154205
>[!NOTE]
155206
> Due to the sensitivity of the key, you will not be able to see the detail values of the key when the command returns. The system will display it as null.
156207
@@ -208,25 +259,26 @@ While you can set up as many OTLP-configured endpoints as you like, each endpoin
208259

209260
```azurecli
210261
az containerapp env telemetry otlp add \
211-
--resource-group <YOUR_RESOURCE_GROUP_NAME> \
212-
--name <YOUR_ENVIRONMENT_NAME> \
262+
--resource-group <RESOURCE_GROUP_NAME> \
263+
--name <ENVIRONMENT_NAME> \
213264
--otlp-name "otlp1" \
214265
--endpoint "ENDPOINT_URL_1" \
215266
--insecure false \
216267
--headers "api-key-1=key" \
217268
--enable-open-telemetry-traces true \
218269
--enable-open-telemetry-metrics true
219270
az containerapp env telemetry otlp add \
220-
--resource-group <YOUR_RESOURCE_GROUP_NAME> \
221-
--name <YOUR_ENVIRONMENT_NAME> \
271+
--resource-group <RESOURCE_GROUP_NAME> \
272+
--name <ENVIRONMENT_NAME> \
222273
--otlp-name "otlp2" \
223274
--endpoint "ENDPOINT_URL_2" \
224275
--insecure true \
225276
--enable-open-telemetry-traces true \
226277
--enable-open-telemetry-logs true
227278
```
279+
228280
>[!NOTE]
229-
> Due to the sensitivity of the headers value, you will not be able to see the detail values of the headers value when the command returns. The system will display them as null.
281+
> Due to the sensitivity of the headers value, you will not be able to see the detail values of the headers value when the command returns. The system will display them as null.
230282
231283
---
232284

@@ -237,7 +289,7 @@ az containerapp env telemetry otlp add \
237289
| `otlp-name` | A name you select to identify your OTLP-configured endpoint. |
238290
| `endpoint` | The URL of the destination that receives collected data. |
239291
| `insecure` | Default true. Defines whether to enable client transport security for the exporter's gRPC connection. If false, the `headers` parameter is required. |
240-
| `headers` | Space-separated values, in 'key=value' format, that provide required information for the OTLP endpoints' security. Example: `"api-key=key other-config-value=value"`. |
292+
| `headers` | Space-separated values, in 'key=value' format, that provides required information for the OTLP endpoints' security. Example: `"api-key=key other-config-value=value"`. |
241293

242294
## Configure Data Destinations
243295

@@ -298,6 +350,8 @@ The following example shows how to use an OTLP endpoint named `customDashboard`.
298350

299351
The following example ARM template shows how you might configure your container app to collect telemetry data using Azure Monitor Application Insights, Datadog, and with a custom OTLP agent named `customDashboard`.
300352

353+
This example works with the parameter file used to retrieve the [Datadog API](#datadog) key from an Azure Key Vault.
354+
301355
Before you deploy this template, replace placeholders surrounded by `<>` with your values.
302356

303357
```json
@@ -311,7 +365,7 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
311365
"destinationsConfiguration": {
312366
"dataDogConfiguration": {
313367
"site": "datadoghq.com",
314-
"key": "<YOUR_DATADOG_KEY>"
368+
"key": "parameters('datadogapikey')]"
315369
},
316370
"otlpConfigurations": [
317371
{
@@ -344,6 +398,8 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
344398
}
345399
```
346400

401+
For more information, see [Microsoft.App/managedEnvironments](/azure/templates/microsoft.app/2024-02-02-preview/managedenvironments).
402+
347403
## Environment variables
348404

349405
The OpenTelemetry agent automatically injects a set of environment variables into your application at runtime.
@@ -369,7 +425,7 @@ These variables are only necessary if you're using both the managed OpenTelemetr
369425

370426
## OpenTelemetry agent costs
371427

372-
You are [billed](./billing.md) for the underlying compute of the agent.
428+
You're [billed](./billing.md) for the underlying compute of the agent.
373429

374430
See the destination service for their billing structure and terms. For example, if you send data to both Azure Monitor Application Insights and Datadog, you're responsible for the charges applied by both services.
375431

0 commit comments

Comments
 (0)