> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/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 fully managed ClickHouse Observability

> [tab] Fully managed
>
> [Beta offering](https://clickhouse.com/docs/reference/settings/beta-and-experimental-features.md#beta-features)
>
> [`otelgen`](https://github.com/krzko/otelgen) is a small Go CLI that generates synthetic OTLP logs, traces and metrics. Use it to send test data to fully managed ClickHouse Observability and explore the results in Search and Chart Explorer.
>
> **1. Prerequisites**
>
> You need an existing fully managed ClickHouse Observability service and network access to its managed telemetry endpoint. See the [fully managed Getting Started guide](https://clickhouse.com/docs/clickstack/observability/getting-started.md).
>
> **2. Install otelgen**
>
> 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
> ```
>
> **3. Set environment variables**
>
> Open your ClickHouse Observability service and go to **Team Settings → Managed Telemetry**. Copy the **OTLP HTTP endpoint** and **API key**.
>
> ![Managed Telemetry in Team Settings showing the masked OTLP HTTP endpoint and API key](https://mintcdn.com/private-7c7dfe99/Zk1feNn6fCQBpold/images/clickstack/getting-started/observability-managed-telemetry.png?fit=max\&auto=format\&n=Zk1feNn6fCQBpold\&q=85\&s=e63a2ac2e6ab996d3fc360ebe0f487a5)
>
> Set the endpoint to its host and port, removing the `https://` prefix. For example, `https://YOUR_OTEL_ENDPOINT:4318` becomes `YOUR_OTEL_ENDPOINT:4318`. Do not append a signal path such as `/v1/logs`.
>
> ```shell theme={null}
> export OTEL_ENDPOINT='YOUR_OTEL_ENDPOINT:4318'
> printf "API key: "
> read -r -s OTEL_API_KEY
> printf "\n"
> export OTEL_API_KEY
> ```
>
> The commands below use `--protocol http` without `--insecure`, so `otelgen` connects over HTTPS with certificate verification. Removing `https://` from the endpoint argument does not disable TLS. Your managed telemetry API key authenticates each request.
>
> **4. Generate traces**
>
> Send a short burst of multi-span traces:
>
> ```shell theme={null}
> otelgen --otel-exporter-otlp-endpoint "${OTEL_ENDPOINT}" \
>   --header "authorization=Bearer ${OTEL_API_KEY}" \
>   --protocol http \
>   --rate 2 --duration 10 \
>   traces multi
> ```
>
> `--rate` is traces per second and `--duration` is the run length in seconds. Omit `--insecure` so the connection uses HTTPS with certificate verification.
>
> **5. Generate logs**
>
> ```shell theme={null}
> otelgen --otel-exporter-otlp-endpoint "${OTEL_ENDPOINT}" \
>   --header "authorization=Bearer ${OTEL_API_KEY}" \
>   --protocol http \
>   --rate 2 \
>   logs multi --duration 10
> ```
>
> **6. Generate metrics**
>
> Run the following command to generate metrics, then press `Ctrl+C` after a few seconds to stop it.
>
> ```shell theme={null}
> otelgen --otel-exporter-otlp-endpoint "${OTEL_ENDPOINT}" \
>   --header "authorization=Bearer ${OTEL_API_KEY}" \
>   --protocol http \
>   --rate 2 \
>   metrics sum
> ```
>
> `otelgen` also supports `gauge`, `histogram`, `up-down-counter` and `exponential-histogram` subcommands under `metrics`.
>
> **7. Verify in ClickHouse Observability**
>
> In your ClickHouse Observability service, open **Search** and switch between the **Logs** and **Traces** sources to confirm new events. Set the time range to **Last 15 minutes** and look for the default service name `otelgen`.
>
> Open **Chart Explorer**, select **Metrics**, and chart `otelgen.metrics.sum` to verify metrics ingestion.

> [tab] Self-managed
>
> [`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 observability UI.
>
> This guide assumes the collector is already running with OTLP endpoints on `4317` (gRPC) and `4318` (HTTP).
>
> **1. Prerequisites**
>
> This guide assumes you have completed the [Getting Started Guide for ClickHouse Observability — Self-managed](https://clickhouse.com/docs/clickstack/self-configured/getting-started/managed.md) 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](https://clickhouse.com/docs/clickstack/self-configured/ingesting-data/collector.md#securing-the-collector-self-configured) with an `OTLP_AUTH_TOKEN`, keep that value handy.
>
> **2. Install otelgen**
>
> 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
> ```
>
> **3. Set environment variables**
>
> 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`.
>
> > [!NOTE]
> >
> > **Unsecured collector**
> >
> > The ClickStack OpenTelemetry collector is unauthenticated by default. If you haven't followed [Securing the collector](https://clickhouse.com/docs/clickstack/self-configured/ingesting-data/collector.md#securing-the-collector-self-configured) to set an `OTLP_AUTH_TOKEN`, skip `OTLP_AUTH_TOKEN` here and drop the `--header` flag from the commands below.
>
> **4. Generate traces**
>
> 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.
>
> **5. Generate logs**
>
> ```shell theme={null}
> otelgen --otel-exporter-otlp-endpoint ${OTEL_ENDPOINT} \
>   --header "authorization=${OTLP_AUTH_TOKEN}" \
>   --protocol grpc --insecure \
>   --rate 2 --duration 10 \
>   logs multi
> ```
>
> **6. Generate metrics**
>
> 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`.
>
> **7. Verify in the observability UI**
>
> Open the observability 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.
