Menu
DocumentationGrafana AlloyCollect and forward dataCollect Datadog traces and metrics
Open source

Receive traces and metrics from Datadog-instrumented applications

You can configure Alloy to collect Datadog traces and metrics and forward them to any OpenTelemetry-compatible database.

This topic describes how to:

  • Configure metrics and traces delivery.
  • Configure the Alloy Datadog Receiver.
  • Configure the Datadog Agent to forward metrics to the Alloy Datadog Receiver.

Before you begin

  • Ensure that at least one instance of the Datadog Agent is collecting metrics and/or traces.
  • Identify where you will write collected metrics. Metrics can be written to Prometheus or any other OTel-compatible database such as Grafana Mimir, Grafana Cloud, or Grafana Enterprise Metrics. Traces can be written to Grafana Tempo, Grafana Cloud, or Grafana Enterprise Traces.
  • Be familiar with the concept of Components in Alloy.

Configure metrics delivery

Before components can collect Datadog metrics, you must have a component responsible for writing those metrics somewhere.

The otelcol.exporter.otlp component is responsible for delivering OTLP data to OTel-compatible endpoints.

  1. Add the following otelcol.exporter.otlp component to your configuration file.

    alloy
    otelcol.exporter.otlp "default" {
      client {
        endpoint = "<OTLP_ENDPOINT_URL>"
        auth     = otelcol.auth.basic.auth.handler
      }
    }

    Replace the following:

    • <OTLP_ENDPOINT_URL>: The full URL of the OTel-compatible endpoint where metrics and traces will be sent, such as https://otlp-gateway-prod-eu-west-2.grafana.net/otlp.
  2. If your endpoint requires basic authentication, paste the following inside the endpoint block.

    alloy
    basic_auth {
      username = "<USERNAME>"
      password = "<PASSWORD>"
    }

    Replace the following:

    • <USERNAME>: The basic authentication username.
    • <PASSWORD>: The basic authentication password or API key.

Configure Datadog Receiver

  1. Add the following otelcol.processor.batch component to your configuration file.

    alloy
    otelcol.processor.batch "default" {
      output {
        metrics = [otelcol.exporter.otlp.default.input]
        traces  = [otelcol.exporter.otlp.default.input]
      }
    }
  2. Add the following otelcol.processor.deltatocumulative component to your configuration file.

    alloy
    otelcol.processor.deltatocumulative "default" {
      max_stale = “<MAX_STALE>”
      max_streams = <MAX_STREAMS>
      output {
        metrics = [otelcol.processor.batch.default.input]
      }
    }

    Replace the following:

    • <MAX_STALE>: How long until a series not receiving new samples is removed, such as “5m”.
    • <MAX_STREAMS>: The upper limit of streams to track. New streams exceeding this limit are dropped.
  3. Add the following otelcol.receiver.datadog component to your configuration file.

    alloy
    otelcol.receiver.datadog "default" {
      endpoint = “<HOST>:<PORT>”
      output {
        metrics = [otelcol.processor.deltatocumulative.default.input]
        traces  = [otelcol.processor.batch.default.input]
      }
    }

    Replace the following:

    • <HOST>: The host address where the receiver will listen.
    • <PORT>: The port where the receiver will listen.
  4. If your endpoint requires basic authentication, paste the following inside the endpoint block.

    alloy
    basic_auth {
      username = "<USERNAME>"
      password = "<PASSWORD>"
    }

    Replace the following:

    • <USERNAME>: The basic authentication username.
    • <PASSWORD>: The basic authentication password or API key.

Configure Datadog Agent to forward metrics to the Datadog Receiver

You can set up your Datadog Agent to forward Datadog metrics simultaneously to Alloy and Datadog.

We recommend this approach for current Datadog users who want to try using Alloy.

  1. Add the following environment variable to your datadog-agent installation.

    bash
    DD_ADDITIONAL_ENDPOINTS='{"http://<DATADOG_RECEIVER_HOST>:<DATADOG_RECEIVER_HOST>": ["datadog-receiver"]}'

    Replace the following:

    • <DATADOG_RECEIVER_HOST>: The hostname where the Alloy receiver is found.
    • <DATADOG_RECEIVER_PORT>: The port where the Alloy receiver is exposed.

Alternatively, you might want your Datadog Agent to send metrics only to Alloy. You can do this by setting up your Datadog Agent in the following way:

  1. Replace the DD_URL in the configuration YAML:

    yaml
     dd_url: http://<DATADOG_RECEIVER_HOST>:<DATADOG_RECEIVER_PORT>

Or by setting an environment variable:

bash
DD_DD_URL='{"http://<DATADOG_RECEIVER_HOST>:<DATADOG_RECEIVER_HOST>": ["datadog-receiver"]}'

Run Alloy with the Datadog Receiver

Some of the components used here are experimental. In order to run them, you need to start Alloy with additional command line flags:

bash
alloy run config.alloy --stability.level=experimental