> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate synthetic OpenTelemetry data with otelgen

> Use otelgen to send synthetic logs, traces and metrics to a ClickStack OpenTelemetry collector

[`otelgen`](https://github.com/krzko/otelgen) is a small Go CLI that generates synthetic OTLP logs, traces and metrics. Use it to confirm that an existing ClickStack OpenTelemetry collector is accepting data and that events surface in the ClickStack UI.

This guide assumes the collector is already running with OTLP endpoints on `4317` (gRPC) and `4318` (HTTP).

<Tabs>
  <Tab title="Managed ClickStack">
    <Steps>
      <Step>
        <h3 id="prerequisites-managed">
          Prerequisites
        </h3>

        This guide assumes you have completed the [Getting Started Guide for Managed ClickStack](/clickstack/deployment/managed) and have an OpenTelemetry collector running with the OTLP gRPC (`4317`) and HTTP (`4318`) endpoints reachable from the machine you run `otelgen` on. If you [secured the collector](/clickstack/ingesting-data/collector#securing-the-collector) with an `OTLP_AUTH_TOKEN`, keep that value handy.
      </Step>

      <Step>
        <h3 id="install-otelgen-managed">
          Install otelgen
        </h3>

        Install with Homebrew:

        ```shell theme={null}
        brew install krzko/tap/otelgen
        ```

        Or install with Go:

        ```shell theme={null}
        go install github.com/krzko/otelgen@latest
        ```
      </Step>

      <Step>
        <h3 id="set-env-vars-managed">
          Set environment variables
        </h3>

        Export the collector endpoint and, if the collector is secured, the auth token:

        ```shell theme={null}
        export OTEL_ENDPOINT=<host>:4317
        export OTLP_AUTH_TOKEN=<your_otlp_auth_token>
        ```

        Use the host and port of your collector. For a collector running on the same machine, this is `localhost:4317`.

        <Info>
          **Unsecured collector**

          The ClickStack OpenTelemetry collector is unauthenticated by default. If you haven't followed [Securing the collector](/clickstack/ingesting-data/collector#securing-the-collector) to set an `OTLP_AUTH_TOKEN`, skip `OTLP_AUTH_TOKEN` here and drop the `--header` flag from the commands below.
        </Info>
      </Step>

      <Step>
        <h3 id="generate-traces-managed">
          Generate traces
        </h3>

        Send a short burst of multi-span traces:

        ```shell theme={null}
        otelgen --otel-exporter-otlp-endpoint ${OTEL_ENDPOINT} \
          --header "authorization=${OTLP_AUTH_TOKEN}" \
          --protocol grpc --insecure \
          --rate 2 --duration 10 \
          traces multi
        ```

        `--rate` is traces per second and `--duration` is the run length in seconds. `--insecure` disables TLS on the gRPC connection, which is needed when pointing `otelgen` at the collector's plaintext OTLP port.
      </Step>

      <Step>
        <h3 id="generate-logs-managed">
          Generate logs
        </h3>

        ```shell theme={null}
        otelgen --otel-exporter-otlp-endpoint ${OTEL_ENDPOINT} \
          --header "authorization=${OTLP_AUTH_TOKEN}" \
          --protocol grpc --insecure \
          --rate 2 --duration 10 \
          logs multi
        ```
      </Step>

      <Step>
        <h3 id="generate-metrics-managed">
          Generate metrics
        </h3>

        The metrics subcommands don't honor `--duration`. Run the command and press `Ctrl+C` after a few seconds to stop it.

        ```shell theme={null}
        otelgen --otel-exporter-otlp-endpoint ${OTEL_ENDPOINT} \
          --header "authorization=${OTLP_AUTH_TOKEN}" \
          --protocol grpc --insecure \
          --rate 2 \
          metrics sum
        ```

        `otelgen` also supports `gauge`, `histogram`, `up-down-counter` and `exponential-histogram` subcommands under `metrics`.
      </Step>

      <Step>
        <h3 id="verify-managed">
          Verify in ClickStack
        </h3>

        Open the ClickStack UI from the ClickHouse Cloud console. In the `Search` view, switch the source between `Logs` and `Traces` to confirm new events. Set the time range to `Last 15 minutes`. Open the `Chart Explorer`, select `Metrics`, and chart one of the metric names produced by `otelgen` (for example `otelgen.metrics.sum`) to verify metrics ingestion.
      </Step>
    </Steps>
  </Tab>

  <Tab title="ClickStack Open Source">
    <Steps>
      <Step>
        <h3 id="prerequisites-oss">
          Prerequisites
        </h3>

        This guide assumes you have started Open Source ClickStack using the [instructions for the all-in-one image](/clickstack/getting-started/oss), and that the OTLP endpoints (`4317` gRPC and `4318` HTTP) are reachable. You also need the ingestion API key from the HyperDX UI under `Team Settings > API Keys`.
      </Step>

      <Step>
        <h3 id="install-otelgen-oss">
          Install otelgen
        </h3>

        Install with Homebrew:

        ```shell theme={null}
        brew install krzko/tap/otelgen
        ```

        Or install with Go:

        ```shell theme={null}
        go install github.com/krzko/otelgen@latest
        ```
      </Step>

      <Step>
        <h3 id="set-env-vars-oss">
          Set environment variables
        </h3>

        Export the collector endpoint and the ingestion API key:

        ```shell theme={null}
        export OTEL_ENDPOINT=localhost:4317
        export CLICKSTACK_API_KEY=<your_ingestion_api_key>
        ```
      </Step>

      <Step>
        <h3 id="generate-traces-oss">
          Generate traces
        </h3>

        Send a short burst of multi-span traces:

        ```shell theme={null}
        otelgen --otel-exporter-otlp-endpoint ${OTEL_ENDPOINT} \
          --header "authorization=${CLICKSTACK_API_KEY}" \
          --protocol grpc --insecure \
          --rate 2 --duration 10 \
          traces multi
        ```

        `--rate` is traces per second and `--duration` is the run length in seconds. `--insecure` enables plaintext gRPC against the local collector.
      </Step>

      <Step>
        <h3 id="generate-logs-oss">
          Generate logs
        </h3>

        ```shell theme={null}
        otelgen --otel-exporter-otlp-endpoint ${OTEL_ENDPOINT} \
          --header "authorization=${CLICKSTACK_API_KEY}" \
          --protocol grpc --insecure \
          --rate 2 --duration 10 \
          logs multi
        ```
      </Step>

      <Step>
        <h3 id="generate-metrics-oss">
          Generate metrics
        </h3>

        The metrics subcommands don't honor `--duration`. Run the command and press `Ctrl+C` after a few seconds to stop it.

        ```shell theme={null}
        otelgen --otel-exporter-otlp-endpoint ${OTEL_ENDPOINT} \
          --header "authorization=${CLICKSTACK_API_KEY}" \
          --protocol grpc --insecure \
          --rate 2 \
          metrics sum
        ```

        `otelgen` also supports `gauge`, `histogram`, `up-down-counter` and `exponential-histogram` subcommands under `metrics`.
      </Step>

      <Step>
        <h3 id="verify-oss">
          Verify in ClickStack
        </h3>

        Visit [http://localhost:8080](http://localhost:8080) to open the ClickStack UI. In the `Search` view, switch the source between `Logs` and `Traces` to confirm new events. Set the time range to `Last 15 minutes`. Open the `Chart Explorer`, select `Metrics`, and chart one of the metric names produced by `otelgen` (for example `otelgen.metrics.sum`) to verify metrics ingestion.
      </Step>
    </Steps>
  </Tab>
</Tabs>
