Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update opentelemetry-agents.md #123608

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 112 additions & 7 deletions articles/container-apps/opentelemetry-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ This article shows you how to set up and configure an OpenTelemetry agent for yo

## Configure an OpenTelemetry agent

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.
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)).

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


## Prerequisites

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.
Expand Down Expand Up @@ -54,7 +53,7 @@ The following table shows you what type of data you can send to each destination

## Azure Monitor Application Insights

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

# [ARM template](#tab/arm)

Expand Down Expand Up @@ -91,6 +90,38 @@ az containerapp env telemetry app-insights set \
--enable-open-telemetry-logs true
```

# [Terraform](#tab/terraform)

```hcl
resource "azapi_update_resource" "app_insights_open_telemetry_integration" {
name = azurerm_container_app_environment.managed_environment.name
parent_id = azurerm_resource_group.resource_group.id
type = "Microsoft.App/managedEnvironments@2023-11-02-preview"
body = jsonencode({
properties = {
appInsightsConfiguration = {
connectionString = azurerm_application_insights.applicationinsights.connection_string
}
appLogsConfiguration = {
destination = "log-analytics"
logAnalyticsConfiguration = {
customerId = azurerm_log_analytics_workspace.workspace.workspace_id
sharedKey = azurerm_log_analytics_workspace.workspace.primary_shared_key
}
}
openTelemetryConfiguration = {
tracesConfiguration = {
destinations = ["appInsights"]
}
logsConfiguration = {
destinations = ["appInsights"]
}
}
}
})
}
```

---

## Datadog
Expand Down Expand Up @@ -133,7 +164,6 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
}
```


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

Before you run this command, replace placeholders surrounded by `<>` with your values.
Expand All @@ -146,6 +176,34 @@ az containerapp env telemetry data-dog set \
--enable-open-telemetry-metrics true
```

# [Terraform](#tab/terraform)

```hcl
resource "azapi_update_resource" "app_insights_open_telemetry_integration" {
name = azurerm_container_app_environment.managed_environment.name
parent_id = azurerm_resource_group.resource_group.id
type = "Microsoft.App/managedEnvironments@2023-11-02-preview"
body = jsonencode({
properties = {
openTelemetryConfiguration = {
destinationsConfiguration = {
dataDogConfiguration = {
site = "<YOUR_DATADOG_SUBDOMAIN>.datadoghq.com"
key = "<YOUR_DATADOG_KEY>"
}
}
tracesConfiguration = {
destinations = ["dataDog"]
}
metricsConfiguration = {
destinations = ["dataDog"]
}
}
}
})
}
```

---

## OTLP endpoint
Expand Down Expand Up @@ -214,6 +272,53 @@ az containerapp env telemetry otlp add \
--enable-open-telemetry-logs true
```

# [Terraform](#tab/terraform)

```hcl
resource "azapi_update_resource" "app_insights_open_telemetry_integration" {
name = azurerm_container_app_environment.managed_environment.name
parent_id = azurerm_resource_group.resource_group.id
type = "Microsoft.App/managedEnvironments@2023-11-02-preview"
body = jsonencode({
properties = {
openTelemetryConfiguration = {
destinationsConfiguration = {
otlpConfigurations = [
{
name = "otlp1"
endpoint = "ENDPOINT_URL_1"
insecure = false
headers = "api-key-1=key"
},
{
name = "otlp2"
endpoint = "ENDPOINT_URL_2"
insecure = true
}
]
}
logsConfiguration = {
destinations = [
"otlp2"