Sending Test data to OTEL Collector

Cloud TunedCloud Tuned
2 min read

Introduction

On occasion you may find yourself in a situation where you have a project setup and you need to make sure your observability stack is working as expected. On this article we will explore a number of alternatives you can deploy to simulate some test data and send it to the OTEL collector.

Possible Approaches

To simulate sending test data to a running OpenTelemetry Collector, several methods can be employed:

1. Using curl with OTLP/HTTP:

This method involves sending OTLP (OpenTelemetry Protocol) formatted data over HTTP using the curl command-line tool.

  • Prepare the data:

    Create a JSON file (e.g., span.json) containing the OTLP trace, metric, or log data you wish to send.

  • Send the data:

    Execute a curl command similar to the following, replacing localhost:4318 with the actual address and port where your Collector's OTLP HTTP receiver is configured:

curl -i http://localhost:4318/v1/traces -X POST -H "Content-Type: application/json" -d @span.json

2. Utilizing otelgen or telemetrygen:

These are command-line tools specifically designed for generating synthetic telemetry data for the OpenTelemetry Collector.

  • Installation:

    Install otelgen or telemetrygen (often available as Go binaries or Docker images).

  • Generation and Sending:

    Use the tool's commands to generate the desired type and volume of telemetry data and direct it to your local Collector's OTLP receiver. For example:

otelgen traces --otlp-endpoint=localhost:4317 --traces-per-second=10

3. Employing a Client Library/SDK:

Develop a small application in your preferred programming language using an OpenTelemetry client library/SDK.

  • Instrument your code: Use the SDK to create and export telemetry data (spans, metrics, logs).
  • Configure the exporter: Configure the SDK's OTLP exporter to send data to your local Collector's OTLP endpoint (e.g., localhost:4317 for gRPC or localhost:4318 for HTTP).

4. Using a Debug Exporter in the Collector:

For basic verification and troubleshooting, configure a debug exporter in your Collector's configuration.

  • Configure the Collector:

    Add a debug exporter to your Collector's exporters section and include it in the relevant pipeline (e.g., traces).

  • Send data:

    Use any of the above methods to send data to the Collector. The debug exporter will print the received and processed telemetry data to the Collector's logs, allowing for inspection.

Important Considerations:

  • Collector Configuration:

    Ensure your local OpenTelemetry Collector is configured with a receiver (e.g., OTLP) listening on the correct address and port to receive the test data.

  • Data Format:

    The test data should conform to the OpenTelemetry Protocol (OTLP) specification.

  • Network Connectivity:

    Verify that your client can reach the Collector on the specified address and port.

0
Subscribe to my newsletter

Read articles from Cloud Tuned directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Cloud Tuned
Cloud Tuned