> ## 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.

# NestJS

> NestJS setup and configuration for ClickHouse Observability and self-managed deployments.

Use the ClickStack Node.js SDK to collect telemetry from your NestJS application and send it to ClickHouse Observability. It includes NestJS request instrumentation and captures console output.

This guide integrates:

## Install the SDK

Use Node.js 22.15 or later:

```shell theme={null}
npm install @clickhouse/clickstack-node
```

## Configure your destination

> [tab] Fully managed
>
> [Beta offering](https://clickhouse.com/docs/reference/settings/beta-and-experimental-features.md#beta-features)
>
> Open **Team Settings → Data → Managed Telemetry** in your service and copy the **OTLP HTTP endpoint** and **API key**. Use the complete HTTPS endpoint, including its port:
>
> ```shell theme={null}
> export OTEL_EXPORTER_OTLP_ENDPOINT='https://YOUR_OTEL_ENDPOINT:4318'
> export OTEL_EXPORTER_OTLP_HEADERS='authorization=Bearer%20YOUR_INGESTION_API_KEY'
> export OTEL_EXPORTER_OTLP_PROTOCOL='http/protobuf'
> ```

> [tab] Self-managed
>
> Use your collector's OTLP HTTP endpoint and ingestion key. Use `http://` instead of `https://` if your collector does not have TLS configured. For collector setup, see [Ingesting with OpenTelemetry](https://clickhouse.com/docs/clickstack/observability/ingesting-data/opentelemetry.md#self-managed).
>
> ```shell theme={null}
> export OTEL_EXPORTER_OTLP_ENDPOINT='https://YOUR_COLLECTOR_HOST:4318'
> export OTEL_EXPORTER_OTLP_HEADERS='authorization=YOUR_INGESTION_API_KEY'
> export OTEL_EXPORTER_OTLP_PROTOCOL='http/protobuf'
> ```

## Start your application

Set `OTEL_SERVICE_NAME` to identify your application. Build your NestJS application, then preload the SDK before the compiled entry point:

```shell theme={null}
npm run build
OTEL_SERVICE_NAME='my-nestjs-app' node --import @clickhouse/clickstack-node/register dist/main.js
```

Adjust `dist/main.js` to match your build output. If you use `ts-node` or another transpiler that hooks `require`, use `--require @clickhouse/clickstack-node/register` instead. Keep the SDK and instrumented dependencies external if you bundle your application.

You can continue using NestJS's default console logger. For a custom logger, use a supported integration such as Winston or Pino. For configuration and compatibility details, see the [Node.js guide](https://clickhouse.com/docs/clickstack/observability/ingesting-data/sdks/nodejs.md).

## Verify ingestion

Make a request to a controller and emit a log message. In ClickHouse Observability, select a recent time range and find your application's service name in Logs and Traces. Check Metrics after allowing time for export.
