Edit

Export OpenTelemetry data to Dynatrace in Azure Container Apps

This guide shows how to configure Azure Container Apps to forward logs, traces, and metrics to Dynatrace by using the managed OpenTelemetry agent.

For more information about the managed OpenTelemetry agent, see Set up OpenTelemetry agents in Azure Container Apps.

What you learn

  • Create a Dynatrace ingest token with the required scopes.
  • Configure a Dynatrace OpenTelemetry Protocol (OTLP) destination by using Bicep or the Azure portal.
  • Configure required app environment variables for metrics export.
  • Apply configuration updates to your existing Container Apps environment and app.
  • Verify telemetry in Dynatrace.

Prerequisites

  • An Azure subscription where you can create resource groups and deploy Azure Container Apps resources.
  • A Dynatrace SaaS environment.
  • Azure CLI installed and signed in.
  • Azure Container Apps CLI extension installed.
az extension add --name containerapp --upgrade

Create a Dynatrace ingest token

Create a Dynatrace API token with these scopes:

  • logs.ingest
  • metrics.ingest
  • openTelemetryTrace.ingest

For token creation steps and permission details, see Dynatrace OTLP authentication guidance.

Configure OpenTelemetry destinations

Use one of the following options to configure Dynatrace as an OpenTelemetry endpoint in your Container Apps environment.

Important

Configuring a managed OpenTelemetry destination doesn't automatically produce telemetry. Your application must also be instrumented to emit traces, metrics, and logs by using an OpenTelemetry SDK.

Set CLI variables for the deployment command:

$RESOURCE_GROUP = "<RESOURCE_GROUP_NAME>"
$DYNATRACE_OTLP_ENDPOINT = "https://<TENANT>.live.dynatrace.com/api/v2/otlp"
$DYNATRACE_API_TOKEN = "<DYNATRACE_INGEST_TOKEN>"

Use only the OTLP base endpoint (/api/v2/otlp). Don't append /v1/traces, /v1/metrics, or /v1/logs; the managed agent appends signal paths automatically.

var dynatraceEndpoint = 'https://<TENANT>.live.dynatrace.com/api/v2/otlp'
var dynatraceApiKey = '<DYNATRACE_INGEST_TOKEN>'
var dynatraceAuthHeader = 'Api-Token ${dynatraceApiKey}'
var dynatraceOtlpDestinationName = 'dynatrace-otlp'

resource environment 'Microsoft.App/managedEnvironments@2024-10-02-preview' = {
  name: '<managed-environment-name>'
  location: '<region>'
  properties: {
    openTelemetryConfiguration: {
      destinationsConfiguration: {
        otlpConfigurations: [
          {
            name: dynatraceOtlpDestinationName
            endpoint: dynatraceEndpoint
            protocol: 'http'
            insecure: false
            headers: [
              {
                key: 'Authorization'
                value: dynatraceAuthHeader
              }
            ]
          }
        ]
      }
      tracesConfiguration: {
        destinations: [
          dynatraceOtlpDestinationName
        ]
      }
      logsConfiguration: {
        destinations: [
          dynatraceOtlpDestinationName
        ]
      }
      metricsConfiguration: {
        destinations: [
          dynatraceOtlpDestinationName
        ]
      }
    }
  }
}

To set the required environment variables, use a container app resource block like the following example:

resource app 'Microsoft.App/containerApps@2023-05-01' = {
  name: '<CONTAINER_APP_NAME>'
  location: '<REGION>'
  properties: {
    managedEnvironmentId: environment.id
    template: {
      containers: [
        {
          name: '<CONTAINER_NAME>'
          image: '<IMAGE_NAME>'
          env: [
            {
              name: 'OTEL_SERVICE_NAME'
              value: '<SERVICE_NAME>'
            }
            {
              name: 'OTEL_TRACES_EXPORTER'
              value: 'otlp'
            }
            {
              name: 'OTEL_METRICS_EXPORTER'
              value: 'otlp'
            }
            {
              name: 'OTEL_LOGS_EXPORTER'
              value: 'otlp'
            }
            {
              name: 'OTEL_EXPORTER_OTLP_METRICS_PROTOCOL'
              value: 'http/protobuf'
            }
            {
              name: 'OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE'
              value: 'DELTA'
            }
          ]
        }
      ]
    }
  }
}

Dynatrace requires OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=DELTA to ingest metrics.

For production deployments, pass token values through secure Bicep parameters or Key Vault instead of hardcoding secrets.

After you update the template, deploy the Bicep configuration from the repository root:

az deployment group create `
  --resource-group $RESOURCE_GROUP `
  --template-file infra/main.bicep `
  --parameters @infra/main.parameters.json `
  dynatraceEndpoint="$DYNATRACE_OTLP_ENDPOINT" `
  dynatraceApiKey="$DYNATRACE_API_TOKEN"

Use the same endpoint and token values shown earlier in this guide, including the OTLP base endpoint format.

Your container app is now configured to send telemetry to Dynatrace.

Verify OpenTelemetry data in Dynatrace

After you complete the configuration, your Container App should begin sending telemetry to Dynatrace through the managed OpenTelemetry agent. The fastest way to confirm that metrics, logs, and traces are all arriving from your application is to open the Services app in Dynatrace. The Services app provides a single screen where you can validate all three telemetry signals for your service in one place.

To verify your telemetry:

  1. Open the Services app in Dynatrace.
  2. Locate your Container App service and confirm that metrics, logs, and traces are present for the expected service or environment context.

If you need background on how OpenTelemetry data is ingested into Dynatrace, see the OpenTelemetry getting started guide.

If telemetry is missing or doesn't appear as expected, see the OpenTelemetry troubleshooting guide.