Skip to content

Commit 14bf59f

Browse files
authored
Merge pull request #123608 from jordanbean-msft/patch-3
Update opentelemetry-agents.md
2 parents 6b6b22a + 8d92674 commit 14bf59f

File tree

1 file changed

+111
-5
lines changed

1 file changed

+111
-5
lines changed

articles/container-apps/opentelemetry-agents.md

Lines changed: 111 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This article shows you how to set up and configure an OpenTelemetry agent for yo
2121

2222
## Configure an OpenTelemetry agent
2323

24-
OpenTelemetry agents live within your container app environment. You configure agent settings via an ARM template or Bicep calls to the environment, or through the CLI.
24+
OpenTelemetry agents live within your container app environment. You configure agent settings via an ARM template or Bicep calls to the environment, or through the CLI, or through Terraform (via the [AzAPI provider](https://registry.terraform.io/providers/Azure/azapi/latest/docs)).
2525

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

@@ -53,7 +53,7 @@ The following table shows you what type of data you can send to each destination
5353

5454
## Azure Monitor Application Insights
5555

56-
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.
56+
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, with Azure CLI commands or Terraform.
5757

5858
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.
5959

@@ -99,6 +99,38 @@ az containerapp env telemetry app-insights set \
9999
>[!NOTE]
100100
> 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.
101101
102+
# [Terraform](#tab/terraform)
103+
104+
```hcl
105+
resource "azapi_update_resource" "app_insights_open_telemetry_integration" {
106+
name = azurerm_container_app_environment.managed_environment.name
107+
parent_id = azurerm_resource_group.resource_group.id
108+
type = "Microsoft.App/managedEnvironments@2023-11-02-preview"
109+
body = jsonencode({
110+
properties = {
111+
appInsightsConfiguration = {
112+
connectionString = azurerm_application_insights.applicationinsights.connection_string
113+
}
114+
appLogsConfiguration = {
115+
destination = "log-analytics"
116+
logAnalyticsConfiguration = {
117+
customerId = azurerm_log_analytics_workspace.workspace.workspace_id
118+
sharedKey = azurerm_log_analytics_workspace.workspace.primary_shared_key
119+
}
120+
}
121+
openTelemetryConfiguration = {
122+
tracesConfiguration = {
123+
destinations = ["appInsights"]
124+
}
125+
logsConfiguration = {
126+
destinations = ["appInsights"]
127+
}
128+
}
129+
}
130+
})
131+
}
132+
```
133+
102134
---
103135

104136
## Datadog
@@ -205,6 +237,34 @@ az containerapp env telemetry data-dog set \
205237
>[!NOTE]
206238
> 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.
207239
240+
# [Terraform](#tab/terraform)
241+
242+
```hcl
243+
resource "azapi_update_resource" "app_insights_open_telemetry_integration" {
244+
name = azurerm_container_app_environment.managed_environment.name
245+
parent_id = azurerm_resource_group.resource_group.id
246+
type = "Microsoft.App/managedEnvironments@2023-11-02-preview"
247+
body = jsonencode({
248+
properties = {
249+
openTelemetryConfiguration = {
250+
destinationsConfiguration = {
251+
dataDogConfiguration = {
252+
site = "<YOUR_DATADOG_SUBDOMAIN>.datadoghq.com"
253+
key = "<YOUR_DATADOG_KEY>"
254+
}
255+
}
256+
tracesConfiguration = {
257+
destinations = ["dataDog"]
258+
}
259+
metricsConfiguration = {
260+
destinations = ["dataDog"]
261+
}
262+
}
263+
}
264+
})
265+
}
266+
```
267+
208268
---
209269

210270
## OTLP endpoint
@@ -280,6 +340,53 @@ az containerapp env telemetry otlp add \
280340
>[!NOTE]
281341
> 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.
282342
343+
# [Terraform](#tab/terraform)
344+
345+
```hcl
346+
resource "azapi_update_resource" "app_insights_open_telemetry_integration" {
347+
name = azurerm_container_app_environment.managed_environment.name
348+
parent_id = azurerm_resource_group.resource_group.id
349+
type = "Microsoft.App/managedEnvironments@2023-11-02-preview"
350+
body = jsonencode({
351+
properties = {
352+
openTelemetryConfiguration = {
353+
destinationsConfiguration = {
354+
otlpConfigurations = [
355+
{
356+
name = "otlp1"
357+
endpoint = "ENDPOINT_URL_1"
358+
insecure = false
359+
headers = "api-key-1=key"
360+
},
361+
{
362+
name = "otlp2"
363+
endpoint = "ENDPOINT_URL_2"
364+
insecure = true
365+
}
366+
]
367+
}
368+
logsConfiguration = {
369+
destinations = [
370+
"otlp2"
371+
]
372+
},
373+
tracesConfiguration = {
374+
destinations = [
375+
"otlp1",
376+
"otlp2"
377+
]
378+
},
379+
metricsConfiguration = {
380+
destinations = [
381+
"otlp1"
382+
]
383+
}
384+
}
385+
}
386+
})
387+
}
388+
```
389+
283390
---
284391

285392
| Name | Description |
@@ -310,9 +417,8 @@ To configure an agent, use the `destinations` array to define which agents your
310417
- You can only set up one Application Insights and Datadog endpoint each at a time.
311418
- While you can define more than one OTLP-configured endpoint, each one must have a distinct name.
312419

313-
314-
The following example shows how to use an OTLP endpoint named `customDashboard`. It sends:
315-
- traces to app insights and `customDashboard`
420+
The following example ARM template shows how to use an OTLP endpoint named `customDashboard`. It sends:
421+
- traces to app insights and `customDashboard`
316422
- logs to app insights and `customDashboard`
317423
- metrics to DataDog and `customDashboard`
318424

0 commit comments

Comments
 (0)