For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/opentelemetry/setup/otlp_ingest/logs.md. A documentation index is available at /llms.txt.

Overview

Datadog’s OpenTelemetry Protocol (OTLP) logs intake API endpoint allows applications, managed platforms, and OpenTelemetry Collectors to send logs to Datadog over OTLP HTTP.

Use the direct configuration on this page when you need to send logs without the Datadog Agent or an OpenTelemetry Collector. For production Collector deployments, use Set Up the OpenTelemetry Collector.

If you are sending logs from a managed platform (Cloudflare, Vercel, Heroku, and others), see Managed platforms for the correct endpoint configuration.

Configuration

To send OTLP data to the Datadog OTLP logs intake endpoint, you must configure the OTLP HTTP Protobuf exporter. The process differs depending on whether you are using automatic or manual instrumentation for OpenTelemetry.

Based on your Datadog site, which is : Replace ${YOUR_ENDPOINT} with in the following examples.

Automatic instrumentation

If you are using OpenTelemetry automatic instrumentation, set the following environment variables:

export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="${YOUR_ENDPOINT}" // Replace this with the correct endpoint
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="dd-api-key=${DD_API_KEY}"

Manual instrumentation

If you are using manual instrumentation with OpenTelemetry SDKs, configure the OTLP HTTP Protobuf exporter programmatically using the following examples.

OpenTelemetry SDK logs support for JavaScript and Python is in development. For the latest statuses, see OpenTelemetry Status and Releases.

The Java exporter is OtlpHttpLogRecordExporter. To configure the exporter, use the following code snippet:

import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter;

OtlpHttpLogRecordExporter exporter = OtlpHttpLogRecordExporter.builder()
    .setEndpoint("${YOUR_ENDPOINT}") // Replace this with the correct endpoint
    .addHeader("dd-api-key", System.getenv("DD_API_KEY"))
    .build();

The Go exporter is otlploghttp. To configure the exporter, use the following code snippet:

import "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"

logExporter, err := otlploghttp.New(
    ctx,
    otlploghttp.WithEndpointURL("${YOUR_ENDPOINT}"), // Replace this with the correct endpoint, minus the URL path
    otlploghttp.WithURLPath("/v1/logs"),
    otlploghttp.WithHeaders(
        map[string]string{
            "dd-api-key": os.Getenv("DD_API_KEY"),
        }),
)

OpenTelemetry Collector

If your OpenTelemetry Collector distribution does not include all the components used by Datadog’s recommended Collector setup, configure the OTLP HTTP exporter in your own distribution:

These examples use component identifiers from OpenTelemetry Collector Contrib v0.154.0. For other versions or distributions, use the identifiers that distribution supports.

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

exporters:
  otlp_http:
    logs_endpoint: 
    headers:
      dd-api-key: ${env:DD_API_KEY}

service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [otlp_http]

Add any receivers and processors required by your Collector distribution.

For a production deployment using OpenTelemetry Collector Contrib, use the recommended OpenTelemetry Collector setup. It also configures sending-queue batching, resource detection, and host metadata enrichment.

Troubleshooting

Error: 403 Forbidden

If you receive a 403 Forbidden error when sending logs to the Datadog OTLP logs intake endpoint, it indicates one potential issue:

  • The endpoint URL is incorrect for your organization.
    Solution: Use the correct endpoint URL for your organization. Your site is , so you need to use the endpoint.

Further reading