DEV Community

Cover image for OpenTelemetry Collector Dynatrace setup: traces, metrics and logs over OTLP/HTTP
Span Observer
Span Observer

Posted on Originally published at span.observer

OpenTelemetry Collector Dynatrace setup: traces, metrics and logs over OTLP/HTTP

Your services already emit OpenTelemetry traces, metrics and logs, but each one sends them its own way. An OpenTelemetry Collector Dynatrace setup fixes that mess: one exit point, one token, one configuration to read during an incident.

For an SRE, the stakes are concrete. A badly configured export means lost spans, wrong SLIs and a longer MTTR on the day you need to understand an outage. Centralising export in a Collector reduces toil: you change an endpoint or a token in one place.

This tutorial applies to both Dynatrace SaaS and Dynatrace Managed. Differences (endpoint, ActiveGate, queries) are flagged at each step.

Goal and prerequisites

By the end, a Collector runs in Docker, receives OTLP from your applications and forwards traces, metrics and logs to Dynatrace over OTLP/HTTP. You will also know how to check that the data arrives.

  • A Dynatrace SaaS environment, or a Managed cluster with an environment ActiveGate;
  • Docker installed on the machine that will host the Collector;
  • an application already instrumented with an OpenTelemetry SDK (see end-to-end OpenTelemetry with Dynatrace);
  • an API token with the ingest scopes described in step 2.

OpenTelemetry Collector Dynatrace configuration, step by step

Step 1 — Choose a distribution

Two sensible choices:

  • Collector contrib (otel/opentelemetry-collector-contrib): the community distribution, very complete, with every component;
  • Dynatrace distribution (ghcr.io/dynatrace/dynatrace-otel-collector/dynatrace-otel-collector): a selection of components tested and supported by Dynatrace, including those used here.

If you want vendor support, take the Dynatrace distribution. If you need an unusual component, take contrib. Either way, pin an exact image version: a Collector that changes version on its own is a source of incidents.

Step 2 — Create the API token

In Dynatrace, open Access tokens and create a token dedicated to the Collector with these scopes:

  • openTelemetryTrace.ingest for traces;
  • metrics.ingest for metrics;
  • logs.ingest for logs.

One token per Collector, nothing beyond these scopes. If it leaks, you revoke a single token without cutting the other flows.

Step 3 — Find the OTLP endpoint

The Dynatrace OTLP API accepts OTLP/HTTP (protobuf) only. The Collector appends /v1/traces, /v1/metrics and /v1/logs to the base itself:

# Dynatrace SaaS
https://{env-id}.live.dynatrace.com/api/v2/otlp

# Dynatrace Managed (via environment ActiveGate)
https://{activegate-host}:9999/e/{env-id}/api/v2/otlp
Enter fullscreen mode Exit fullscreen mode

In Managed, the /e/{env-id}/ path identifies the environment. Check the exact port and domain of your ActiveGate in the Dynatrace OTLP API documentation.

Step 4 — Write otel-collector-config.yaml

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 75
    spike_limit_percentage: 15
  resource:
    attributes:
      - key: deployment.environment
        value: production
        action: upsert
  cumulativetodelta: {}
  batch:
    send_batch_size: 1000
    timeout: 5s

exporters:
  otlphttp:
    endpoint: ${env:DT_ENDPOINT}
    headers:
      Authorization: "Api-Token ${env:DT_API_TOKEN}"
  debug:
    verbosity: basic

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resource, batch]
      exporters: [otlphttp]
    metrics:
      receivers: [otlp]
      processors: [memory_limiter, resource, cumulativetodelta, batch]
      exporters: [otlphttp]
    logs:
      receivers: [otlp]
      processors: [memory_limiter, resource, batch]
      exporters: [otlphttp]
Enter fullscreen mode Exit fullscreen mode

The critical lines:

  • otlp receiver: your applications can talk gRPC (4317) or HTTP (4318) to the Collector. Only the export to Dynatrace must use HTTP;
  • memory_limiter first: it refuses data before the Collector is killed for lack of memory;
  • resource: adds a shared attribute, useful for filtering by environment in your queries;
  • batch last: it groups sends and limits the number of requests;
  • Authorization: the value starts with Api-Token followed by a space, then the token. The token comes from an environment variable, never from the file.

Step 5 — Handle metric temporality

Dynatrace expects OTLP metrics with delta temporality. Many SDKs and receivers produce cumulative by default. Two options: configure the SDK for delta, or let the cumulativetodelta processor convert in the Collector, as in the metrics pipeline above. This processor keeps state in memory: with several replicas, make sure a given series always reaches the same Collector. For histograms, see also metrics and histograms with OpenPipeline.

Step 6 — Deploy with Docker

export DT_ENDPOINT="https://{env-id}.live.dynatrace.com/api/v2/otlp"
export DT_API_TOKEN="dt0c01.XXXX"   # do not commit

docker run -d --name otel-collector \
  -p 4317:4317 -p 4318:4318 \
  -e DT_ENDPOINT -e DT_API_TOKEN \
  -v "$(pwd)/otel-collector-config.yaml:/etc/otelcol/config.yaml" \
  ghcr.io/dynatrace/dynatrace-otel-collector/dynatrace-otel-collector:<version> \
  --config=/etc/otelcol/config.yaml
Enter fullscreen mode Exit fullscreen mode

Then point your applications at the Collector, for example OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318.

Kubernetes: the same file becomes a ConfigMap, the token a Secret injected as an environment variable. The OpenTelemetry project’s Helm chart or the Dynatrace Operator can deploy the Collector; choose a Deployment for the central gateway and a DaemonSet for per-node collection. Remember the cumulativetodelta constraint if you run several replicas.

How to check that it works

  1. Collector logs: docker logs -f otel-collector. At start-up you should see « Everything is ready ». An export error shows the HTTP code returned by Dynatrace.
  2. Debug exporter: temporarily add debug to a pipeline’s exporters. The Collector then writes what it receives to its logs. If nothing appears, the problem is on the application side, not Dynatrace.
  3. DQL in a Notebook (SaaS):
fetch spans, from: now() - 15m
| filter deployment.environment == "production"
| summarize spans = count(), by: {service.name}
| sort spans desc
Enter fullscreen mode Exit fullscreen mode

Same principle for logs with fetch logs. In Managed, without Grail, open the distributed traces view instead and filter on the service name. To go further with DQL and OTLP data in SaaS, see module 8 of the SaaS learning path.

Managed and SaaS: what changes

Item Dynatrace SaaS Dynatrace Managed
Endpoint {env-id}.live.dynatrace.com/api/v2/otlp ActiveGate or cluster domain + /e/{env-id}/api/v2/otlp
Certificate public often internal: add the CA to the Collector
Analysis Grail, DQL, Notebooks classic views (distributed traces, data explorer)

Troubleshooting

Symptom Likely cause Fix
401 Unauthorized token missing, malformed or revoked check the Api-Token prefix and the environment variable
403 Forbidden missing scope add the scope for that signal to the token
404 Not Found wrong path base /api/v2/otlp without /v1/...; /e/{env-id} in Managed
Failure with the otlp exporter gRPC not supported by Dynatrace use otlphttp
Metrics missing or rejected cumulative temporality add cumulativetodelta or switch the SDK to delta

Best practices

  • One token per Collector, ingest scopes only, stored in a secret.
  • Always memory_limiter first and batch last in the pipeline.
  • Pin the image version and upgrade it deliberately.
  • Monitor the Collector itself: an export that fails silently skews your SLOs.
  • Remove the debug exporter once verification is done.

Frequently asked questions

Do I need a Collector if OneAgent is already installed?

Not necessarily. OneAgent can capture OpenTelemetry data on the hosts it monitors. The Collector becomes useful without OneAgent, to centralise several sources, or to filter and enrich before sending.

Can I send gRPC to Dynatrace?

No, the Dynatrace OTLP API expects OTLP/HTTP. Your applications can talk gRPC to the Collector; the Collector exports over HTTP.

Contrib or Dynatrace distribution?

The Dynatrace distribution covers common cases with vendor support. Contrib offers more components, without that support. The configuration shown here works with both.

Conclusion

A well-configured Collector gives you a readable export chain: one endpoint, one token, three pipelines. You gain a single control point for telemetry, and therefore faster diagnosis when an SLO degrades. Start with traces, check in a Notebook, then add metrics and logs.

span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of Dynatrace LLC. Features change quickly: check endpoints, scopes and components in the official documentation for your version.


Originally published on span.observer. French version: https://span.observer/fr/collector-opentelemetry-dynatrace/.

Top comments (0)