# Build and run
docker-compose up --build
```

Open [http://localhost:5678](http://localhost:5678), create a workflow, and see traces in your [Opik dashboard](https://www.comet.com)!

## Setup Options

### Docker (Recommended)

Create a custom Dockerfile that installs the `n8n-observability` package globally:

```dockerfile
FROM n8nio/n8n:latest

USER root
RUN npm install -g n8n-observability

ENV EXTERNAL_HOOK_FILES=/usr/local/lib/node_modules/n8n-observability/dist/hooks.cjs

USER node
```

Then configure your docker-compose.yml with OTLP settings:

<Tabs>
  <Tab value="Opik Cloud" title="Opik Cloud">
    ```yaml
    services:
      n8n:
        build: .
        environment:
          OTEL_EXPORTER_OTLP_ENDPOINT: "https://www.comet.com/opik/api/v1/private/otel"
          OTEL_EXPORTER_OTLP_HEADERS: "Authorization=${OPIK_API_KEY},Comet-Workspace=default"
          N8N_OTEL_SERVICE_NAME: "my-n8n"
        volumes:
          - n8n_data:/home/node/.n8n
        ports:
          - "5678:5678"

    volumes:
      n8n_data:
    ```

    <Tip>
      To log the traces to a specific project, you can add the
      `projectName` parameter to the `OTEL_EXPORTER_OTLP_HEADERS`
      environment variable:

      ```yaml
      OTEL_EXPORTER_OTLP_HEADERS: "Authorization=${OPIK_API_KEY},Comet-Workspace=default,projectName=my-n8n-project"
      ```
    </Tip>
  </Tab>

  <Tab value="Enterprise deployment" title="Enterprise deployment">
    ```yaml
    services:
      n8n:
        build: .
        environment:
          OTEL_EXPORTER_OTLP_ENDPOINT: "https://<comet-deployment-url>/opik/api/v1/private/otel"
          OTEL_EXPORTER_OTLP_HEADERS: "Authorization=${OPIK_API_KEY},Comet-Workspace=default"
          N8N_OTEL_SERVICE_NAME: "my-n8n"
        volumes:
          - n8n_data:/home/node/.n8n
        ports:
          - "5678:5678"

    volumes:
      n8n_data:
    ```
  </Tab>

  <Tab value="Self-hosted instance" title="Self-hosted instance">
    ```yaml
    services:
      n8n:
        build: .
        environment:
          OTEL_EXPORTER_OTLP_ENDPOINT: "http://localhost:5173/api/v1/private/otel"
          OTEL_EXPORTER_OTLP_HEADERS: "projectName=my-n8n-project"
          N8N_OTEL_SERVICE_NAME: "my-n8n"
        volumes:
          - n8n_data:/home/node/.n8n
        ports:
          - "5678:5678"

    volumes:
      n8n_data:
    ```
  </Tab>
</Tabs>

### Bare Metal / npm

If you're running n8n directly on your machine:

```bash