Configure Grafana Alloy to send traces

Grafana Alloy uses a component-based architecture that allows you to build flexible telemetry pipelines tailored to your specific requirements.

For trace collection, you typically need the following types of components:

  • Receiver components: Accept trace data from applications and other sources
  • Processor components: Transform, filter, or enhance trace data
  • Exporter components: Send processed traces to destinations like Grafana Cloud

The most common component for receiving traces is otelcol.receiver.otlp, which accepts OpenTelemetry Protocol (OTLP) traces from instrumented applications.

To configure trace collection components, you need to edit the configuration file. The example in this milestone includes the otelcol.receiver.otlp component that accepts traces on standard ports, and an OTLP exporter that sends traces to Grafana Cloud using basic authentication.

Alloy adds a default configuration file when you install it.

To configure Alloy, complete the following steps:

  1. Open the configuration file in your preferred text editor. The file location depends on your operating system. For example:

    • Linux: /etc/alloy/config.alloy
    • Windows: %ProgramFiles%\GrafanaLabs\Alloy\config.alloy
  2. Add the basic trace collection configuration with placeholder values:

    alloy
    // Receive OTLP traces on port 4317 (gRPC) and 4318 (HTTP)
    otelcol.receiver.otlp "default" {
      grpc {
        endpoint = "0.0.0.0:4317"
      }
    
      http {
        endpoint = "0.0.0.0:4318"
      }
    
      output {
        traces = [otelcol.processor.batch.default.input]
      }
    }
    // Batch traces before exporting
    otelcol.processor.batch "default" {
        // Wait until we've received 1000 samples, up to a maximum of 2000.
        send_batch_size = 1000
        send_batch_max_size = 2000
        // Or until 2 seconds have elapsed.
        timeout = "2s"
        // When the Alloy has enough batched data, send it to the OpenTelemetry exporter named 'tempo' for traces,
        // or the Prometheus exporter for metrics.
        output {
            traces = [otelcol.exporter.otlp.grafana_cloud_traces.input]
        }
    }
    
    // Export traces to Grafana Cloud
    otelcol.exporter.otlp "grafana_cloud_traces" {
      client {
        endpoint = "<YOUR_GRAFANA_CLOUD_TRACES_ENDPOINT>"
        auth     = otelcol.auth.basic.grafana_cloud_traces.handler
      }
    }
    
    // Configure authentication for Grafana Cloud
    otelcol.auth.basic "grafana_cloud_traces" {
      username = "<YOUR_GRAFANA_CLOUD_INSTANCE_ID>"
      password = "<YOUR_GRAFANA_CLOUD_API_TOKEN>"
    }
  3. Replace the placeholder values in your configuration file with your actual Grafana Cloud credentials:

    • Change <YOUR_GRAFANA_CLOUD_TRACES_ENDPOINT> to your Grafana Cloud traces endpoint, for example, https://tempo-us-central1.grafana.net/tempo
    • Change <YOUR_GRAFANA_CLOUD_INSTANCE_ID> to your instance ID, for example, 123456
    • Change <YOUR_GRAFANA_CLOUD_API_TOKEN> to your API token, for example, glc_eyJhbGciOiJIUzI1NiIsInR5cXXXXXXXVCJ9
    alloy
    // Export traces to Grafana Cloud
    otelcol.exporter.otlp "grafana_cloud_traces" {
      client {
        endpoint = "https://tempo-us-central1.grafana.net/tempo"
        auth     = otelcol.auth.basic.grafana_cloud_traces.handler
      }
    }
    
    // Configure authentication for Grafana Cloud
    otelcol.auth.basic "grafana_cloud_traces" {
      username = "123456"
      password = "glc_eyJhbGciOiJIUzI1NiIsInR5cXXXXXXXVCJ9"
    }
  4. Save and close the configuration file.

In the next milestone, you restart Alloy service and validate your configuration.

More to explore (optional)

At this point in your journey, you can explore the following paths:

Configure Alloy

Alloy configuration reference

Alloy component reference

OpenTelemetry receiver components


page 6 of 9