Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

DuckDB OpenTelemetry Extension

The DuckDB OpenTelemetry Extension lets you ingest OpenTelemetry data from storage or multiple OpenTelemetry protocol standards (OTAP, OTLP) over gRPC/HTTP into DuckDB.

Do analysis on metrics, logs, or traces or export telemetry to anything DuckDB supports using a few lines of SQL statements: data lakes, databases, parquet, vortex, or object storage systems.

Start using duckdb-otlp

  • Get Started - install the extension, query bundled OTLP files, and POST one log over HTTP.
  • WASM Demo - query OTLP JSON, JSONL, and protobuf samples in your browser.
  • Live Ingest Quickstart - POST one OTLP/HTTP log record and query it from DuckDB.

Query and export telemetry

Set up data sources

Reference

  • API Reference - file readers and live ingest functions.
  • Schema Reference - columns for traces, logs, gauges, sums, histograms, and exponential histograms.
  • Live Ingest Reference - otlp_serve, otlp_flush, otlp_stop, otlp_server_list, HTTP endpoints, auth, buffering, and durability.
  • Error Reference - file reader failures and live-ingest error responses.
  • Performance Reference - file formats, projection, file sizes, materialization, and live ingest notes.

Project internals

  • Architecture - how the file readers, Arrow bridge, schema layer, and HTTP ingest server work.
  • Contributing - build, test, and contribute to the project.

Need help?

Get Started

Use the DuckDB OpenTelemetry Extension to query OpenTelemetry files, try the native OTLP/HTTP ingest server, then share live telemetry with other hosts over Quack.

Prerequisites

  • DuckDB 2.0 or later.
  • OpenTelemetry data
  • Docker (if you want to use the server daemon image)

1. Install and Load

-- Install from community repo
INSTALL otlp FROM community;
LOAD otlp;

Alternately, for development and pre-releases, start duckdb with -unsigned and you can install from GitHub:

-- Install unsigned from GitHub pages (nightly/pre-release)
INSTALL otlp from 'https://smithclay.github.io/duckdb-otlp';
LOAD otlp;

2. Read OTLP Files

The table functions accept local paths, globs, and DuckDB-supported remote file systems.

LOAD httpfs;

SELECT time_unix_nano, service_name, severity_text, body
FROM read_otlp_logs('https://github.com/smithclay/duckdb-otlp/raw/refs/heads/main/test/data/otlp_logs.pb')
WHERE severity_text = 'ERROR';

SELECT
    trace_id,
    name,
    duration_time_unix_nano / 1000000 AS duration_ms
FROM read_otlp_traces('https://github.com/smithclay/duckdb-otlp/raw/refs/heads/main/test/data/otlp_traces.pb')
ORDER BY duration_time_unix_nano DESC;

See the Schema Reference for every column emitted by each reader.

3. Stream One Log over OTLP/HTTP

Native builds include the ingest server. You can POST OTLP/HTTP to it, and DuckDB buffers rows in memory before batch commits. When a POST returns 202, DuckDB has accepted the rows, but it has not made them durable yet. DuckDB commits rows after about 5 seconds in the buffer, when admitted request-body bytes reach about 64 MiB, when you call otlp_stop, or when you call otlp_flush.

Start a local server:

SELECT listen_url
FROM otlp_serve('otlp:localhost:4318', token := 'dev-token-123456');

Send one OTLP log record:

curl -sS http://localhost:4318/v1/logs -H 'Authorization: Bearer dev-token-123456' -H 'Content-Type: application/json' -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"curl-demo"}}]},"scopeLogs":[{"logRecords":[{"timeUnixNano":"1704067200000000000","severityText":"INFO","body":{"stringValue":"hello from curl"}}]}]}]}'

Leave the server running for the next steps. The in-memory otlp_logs table it writes to is the same one the queries and the Quack server below read from.

For durable lakehouse ingest, pass catalog to an attached lakehouse catalog. See Stream to Local DuckLake, Stream to Remote DuckLake, Stream to Amazon S3 Tables, or Stream to Cloudflare R2 Data Catalog. To write partitioned Parquet files without a lakehouse catalog, see Stream to Parquet.

4. Query the Data

The server buffers rows in memory and commits them in the background, so a freshly POSTed row may not be visible yet. Force a commit with otlp_flush, then read the table:

SELECT * FROM otlp_flush('otlp:localhost:4318');

SELECT time_unix_nano, service_name, severity_text, body
FROM otlp_logs;

Rows land in the default (in-memory) catalog: logs in otlp_logs, traces in otlp_traces, and metrics in otlp_metrics_gauge, otlp_metrics_sum, otlp_metrics_histogram, and otlp_metrics_exp_histogram. See the Schema Reference for every column.

5. Share with Quack

Quack turns a running DuckDB process into a query server, so other hosts can read its tables over the network. Enable it in the same DuckDB session that is running the ingest server:

INSTALL quack;
LOAD quack;

CALL quack_serve(
    'quack:0.0.0.0:9494',
    token := 'dev-quack-token-123456',
    allow_other_hostname := true
);

SELECT info['ssl_fingerprint'] FROM quack_server_list();

Quack now serves this DuckDB instance — including otlp_logs and the other signal tables — on port 9494. Use a token separate from the ingest token: dev-token-123456 protects OTLP ingest on 4318, and dev-quack-token-123456 protects query access on 9494. On a non-loopback bind Quack serves TLS with a self-signed certificate, and the last query prints the fingerprint clients pin. To accept only same-host connections, bind to quack:localhost:9494 and drop allow_other_hostname. That serves plain HTTP, and clients omit the fingerprint.

Quack grants full SQL read/write access to this DuckDB connection, so treat the token as an administrative credential. Quack is stable in DuckDB 2.0. Run it on trusted networks.

6. Query with Quack from Another Host

On another machine, install Quack, create a secret with the token, attach the remote server, and connect the session to it. Replace SERVER_HOST with the hostname or IP of the machine running the ingest server, and <fingerprint> with the value printed above:

INSTALL quack;
LOAD quack;

CREATE SECRET otlp_quack (
  TYPE quack,
  SCOPE 'quack:SERVER_HOST:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:SERVER_HOST:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>');
CONNECT otel;

Query the signal tables directly:

SELECT time_unix_nano, service_name, severity_text, body
FROM otlp_logs
ORDER BY time_unix_nano DESC
LIMIT 5;

DISCONNECT;

Quack runs each statement inside the remote DuckDB process and streams the result back. See Query with Quack for the full workflow, including the Docker daemon path and one-shot query fallback.

Stop the Servers

When you are done, stop Quack and the ingest server before closing the database. otlp_stop commits remaining buffered rows before it returns:

CALL quack_stop('quack:0.0.0.0:9494');
SELECT status FROM otlp_stop('otlp:localhost:4318');

Next Steps

Common Issues

Extension otlp not found

INSTALL otlp FROM community;
LOAD otlp;

File does not exist

Use a path relative to DuckDB’s current working directory, or pass an absolute path:

SELECT * FROM read_otlp_traces('/full/path/to/traces.jsonl');

Rows posted to the server are not visible yet

Wait for the background commit, or stop the server with otlp_stop('otlp:localhost:4318') before closing the database. Use otlp_flush('otlp:localhost:4318') when the server should keep running and readers need the latest accepted rows before the next scheduled commit.

WASM Demo

Open OTLP JSON, JSONL, and protobuf files in your browser with DuckDB-WASM and duckdb-otlp.

Open the demo in a full page.

Live Ingest Quickstart

Start a local OTLP/HTTP endpoint, POST one log record, and query it from DuckDB.

This quickstart requires the native extension. WASM builds do not include the ingest server. Live ingestion uses HTTP.

Step 1: Start the server

From a DuckDB shell with the extension loaded:

INSTALL otlp FROM community;
LOAD otlp;

SELECT listen_url, auth_token
FROM otlp_serve('otlp:localhost:4318', token := 'dev-token-123456');

Output:

┌────────────────────────┬──────────────────┐
│       listen_url       │    auth_token    │
├────────────────────────┼──────────────────┤
│ http://localhost:4318  │ dev-token-123456 │
└────────────────────────┴──────────────────┘

Leave this DuckDB session running. With no catalog parameter, rows land in the connection’s default catalog: in memory, or in the DuckDB file you opened.

Step 2: POST one log

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer dev-token-123456' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"curl-demo"}}]},"scopeLogs":[{"logRecords":[{"timeUnixNano":"1704067200000000000","severityText":"INFO","body":{"stringValue":"hello from curl"}}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

A 202 Accepted with "status":"buffered" means the server parsed the row and accepted it into the in-memory buffer. You can query it after the next background commit, after otlp_stop, or after otlp_flush.

You can confirm the server is up without auth:

curl -sS http://localhost:4318/healthz
# {"status":"ok"}
curl -sS http://localhost:4318/readyz
# {"status":"ready"}

Step 3: Stop and query

Back in DuckDB, stop the server before closing the database:

SELECT status FROM otlp_stop('otlp:localhost:4318');

otlp_stop commits remaining buffered rows before it returns, so an explicit otlp_flush is not required for this quickstart.

Now query the accepted row:

SELECT time_unix_nano, service_name, severity_text, body
FROM otlp_logs;
┌─────────────────────┬──────────────┬───────────────┬─────────────────┐
│   time_unix_nano    │ service_name │ severity_text │      body       │
├─────────────────────┼──────────────┼───────────────┼─────────────────┤
│ 2024-01-01 00:00:00 │ curl-demo    │ INFO          │ hello from curl │
└─────────────────────┴──────────────┴───────────────┴─────────────────┘

Next steps

How to Install the Extension

Install the DuckDB OpenTelemetry Extension to start querying OpenTelemetry data with SQL.

Install from Community

Install from DuckDB’s community extension repository:

-- Install from DuckDB community extensions
INSTALL otlp FROM community;
LOAD otlp;

DuckDB downloads the pre-built extension for your platform.

Requirements

  • DuckDB 0.10.0 or later
  • Supported platforms:
    • Linux (x86_64, arm64)
    • macOS (Intel, Apple Silicon)
    • Windows (x86_64)

Install the duckdb-otlp CLI

The extension also ships as a standalone binary that receives OTLP over the network, converts OTLP/OTAP files, and queries what it has stored — no DuckDB shell required.

# macOS or Linux (x86_64 or arm64), installs into ~/.local/bin
curl -fsSL https://smithclay.github.io/duckdb-otlp/install.sh | sh

The script picks the latest release for your platform, verifies the download against the release’s SHA256SUMS, and installs a single executable; re-run it to upgrade. Homebrew works too:

brew install smithclay/tap/duckdb-otlp

See the CLI reference for install options, every command, and the release tarballs to install by hand.

Use in Browser (DuckDB-WASM)

Try the extension in your browser without installation:

→ Interactive Demo

The WASM demo supports:

  • JSON, JSONL, and protobuf file reads
  • Loading sample OTLP data
  • Running SQL queries in-browser
  • Uploading your own files

Native builds include the live ingest server.

Build from Source

For development or custom builds, see CONTRIBUTING.md.

Quick Build

# Clone repository
git clone https://github.com/smithclay/duckdb-otlp.git
cd duckdb-otlp

# Install vcpkg dependencies
export VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake

# Build with ninja
GEN=ninja make

# DuckDB shell with extension loaded
./build/release/duckdb

WASM Build

# Build for browser
make wasm_eh

# Output: build/wasm_eh/extension/otlp/otlp.duckdb_extension.wasm

Note: The live ingest server is not available in WASM builds.

Verify Installation

Check that DuckDB loaded the extension:

-- List installed extensions
SELECT * FROM duckdb_extensions() WHERE extension_name = 'otlp';

-- Test with sample data
SELECT count(*) FROM read_otlp_logs('test/data/logs_simple.jsonl');

Next Steps

Troubleshooting

Extension Not Found

Error: Extension "otlp" not found

Ensure you’re using DuckDB 0.10+ and run:

INSTALL otlp FROM community;
LOAD otlp;

Platform Not Supported

If pre-built binaries aren’t available for your platform, build from source.

Live Ingest in WASM

Error: otlp_serve is not implemented for the wasm platform

Use a native DuckDB build for the HTTP ingest functions: otlp_serve, otlp_flush, otlp_stop, and otlp_server_list.

See Also

How to Configure the OpenTelemetry Collector

Use the OpenTelemetry Collector to route telemetry from applications to duckdb-otlp. You can forward OTLP/HTTP to the server image, or write OTLP files for later DuckDB analysis.

Forward to the Server Image

Start a local DuckLake-backed server:

cat > .env <<'EOF'
DUCKDB_MODE=local-ducklake
DUCKDB_OTLP_TOKEN=dev-token-123456

DUCKDB_CATALOG=lake
DUCKLAKE_CATALOG_PATH=/data/ducklake/catalog.duckdb
DUCKLAKE_DATA_PATH=/data/ducklake/storage

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456
EOF

mkdir -p data

docker run --rm --name duckdb-otlp \
  --env-file .env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v "$(pwd)/data:/data" \
  ghcr.io/smithclay/duckdb-otlp:latest

In another terminal, create collector-to-duckdb.yaml:

receivers:
  otlp:
    protocols:
      grpc:
      http:

processors:
  batch:

exporters:
  otlp_http/duckdb:
    endpoint: http://localhost:4318
    headers:
      Authorization: Bearer dev-token-123456

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp_http/duckdb]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp_http/duckdb]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp_http/duckdb]

Run the collector:

otelcol-contrib --config collector-to-duckdb.yaml

Point applications at the collector’s OTLP endpoints:

  • OTLP/gRPC: http://localhost:4317
  • OTLP/HTTP: http://localhost:4318

The collector forwards traces, logs, and metrics to duckdb-otlp, which writes them into DuckLake tables.

If the collector itself runs in Docker, use http://host.docker.internal:4318 for the exporter endpoint. On Linux, add host.docker.internal with Docker’s host-gateway support.

Query Forwarded Telemetry

Flush buffered telemetry and query through the running duckdb-otlp container:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

SELECT service_name, name, count(*) AS spans
FROM lake.main.otlp_traces
GROUP BY service_name, name
ORDER BY spans DESC
LIMIT 20;

DISCONNECT;
SQL

The server image is distroless and has no shell or DuckDB CLI, so run inspection SQL from a host DuckDB process through Quack instead of docker exec ... sh -c.

Write OTLP Files Instead

Use the file exporter when you want files that DuckDB can query without a running server.

Create collector-to-files.yaml:

receivers:
  otlp:
    protocols:
      grpc:
      http:

processors:
  batch:

exporters:
  file/otel-json:
    path: ./otel-export/telemetry.jsonl
    rotation:
      max_megabytes: 50
      max_days: 1
    encoding: json

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [file/otel-json]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [file/otel-json]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [file/otel-json]

Run it:

otelcol-contrib --config collector-to-files.yaml

The collector listens on the OTLP ports and writes JSONL files under ./otel-export/.

To generate protobuf files, switch the exporter to encoding: proto.

Query Exported Files

INSTALL otlp FROM community;
LOAD otlp;

SELECT trace_id, name, duration_time_unix_nano
FROM read_otlp_traces('otel-export/*.jsonl')
ORDER BY start_time_unix_nano DESC
LIMIT 20;

SELECT time_unix_nano, severity_text, body
FROM read_otlp_logs('otel-export/*.jsonl')
WHERE severity_text IN ('ERROR', 'FATAL');

SELECT time_unix_nano, name, coalesce(double_value, int_value::DOUBLE) AS value
FROM read_otlp_metrics_gauge('otel-export/*.jsonl');

Next Steps

How to Point the OpenTelemetry Demo at Local DuckLake

Run the duckdb-otlp server image in local-ducklake mode and send OpenTelemetry Demo traces, logs, and metrics to it over OTLP/HTTP.

The demo keeps its existing observability backends. You add duckdb-otlp as one more collector exporter.

Start the Local DuckLake Server

Create .env:

DUCKDB_MODE=local-ducklake
DUCKDB_OTLP_TOKEN=dev-token-123456

DUCKDB_CATALOG=lake
DUCKLAKE_CATALOG_PATH=/data/ducklake/catalog.duckdb
DUCKLAKE_DATA_PATH=/data/ducklake/storage

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

Start the server:

mkdir -p data

docker run --rm --name duckdb-otlp \
  --env-file .env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v "$(pwd)/data:/data" \
  ghcr.io/smithclay/duckdb-otlp:latest

Leave this container running. It accepts OTLP/HTTP at http://localhost:4318.

Configure the OpenTelemetry Demo Collector

In another terminal, clone the OpenTelemetry Demo:

git clone https://github.com/open-telemetry/opentelemetry-demo.git
cd opentelemetry-demo

Create src/otel-collector/otelcol-config-extras.yml:

exporters:
  otlp_http/duckdb:
    endpoint: http://host.docker.internal:4318
    headers:
      Authorization: Bearer dev-token-123456

service:
  pipelines:
    traces:
      exporters: [otlp, debug, spanmetrics, otlp_http/duckdb]
    logs:
      exporters: [opensearch, debug, otlp_http/duckdb]
    metrics:
      exporters: [otlp_http/prometheus, debug, otlp_http/duckdb]

The OpenTelemetry Demo merges this file with its main collector config. The merge replaces pipeline arrays, so keep the demo’s existing exporters in each list and add otlp_http/duckdb.

On Linux, add host.docker.internal to the otelcol service in docker-compose.yml:

services:
  otelcol:
    extra_hosts:
      - "host.docker.internal:host-gateway"

Docker Desktop for macOS and Windows provides host.docker.internal.

Start the Demo

docker compose up -d

Generate traffic by opening the demo frontend and using the store:

http://localhost:8080

Query the DuckLake Tables

Flush buffered telemetry and query the running duckdb-otlp container:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

SELECT service_name, name, count(*) AS spans
FROM lake.main.otlp_traces
GROUP BY service_name, name
ORDER BY spans DESC
LIMIT 20;

DISCONNECT;
SQL

Inspect recent logs:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT time_unix_nano, service_name, severity_text, body
FROM lake.main.otlp_logs
ORDER BY time_unix_nano DESC
LIMIT 20;

DISCONNECT;
SQL

The server image is distroless and has no shell or DuckDB CLI, so run inspection SQL from a host DuckDB process through Quack instead of docker exec ... sh -c.

Stop Cleanly

Stop the demo:

docker compose down

Stop the DuckLake server:

docker stop duckdb-otlp

During shutdown, the image sends otlp_stop('otlp:0.0.0.0:4318'), so the server commits remaining buffered rows before the process exits.

Troubleshooting

  • If the collector logs connection errors, confirm the duckdb-otlp container is still running and docker logs duckdb-otlp shows OTLP HTTP: 0.0.0.0:4318.
  • If you run the collector in Linux Docker and it cannot resolve host.docker.internal, add the extra_hosts entry above.
  • If the server returns 401, confirm the collector Authorization header matches DUCKDB_OTLP_TOKEN.
  • If you cannot see rows before the next background commit, run otlp_flush before querying.

See Also

OpenTelemetry Demo Example

Use otelcol-config-extras.yml to send OpenTelemetry Demo traces, logs, and metrics to a local duckdb-otlp server running in local-ducklake mode.

Use It

git clone https://github.com/open-telemetry/opentelemetry-demo.git
cd opentelemetry-demo

cp /path/to/duckdb-otlp/site/src/examples/otel-demo/otelcol-config-extras.yml \
  src/otel-collector/otelcol-config-extras.yml

Start duckdb-otlp, then start the demo:

docker compose up -d

See Point the OpenTelemetry Demo at Local DuckLake.

How-to Guides

Use these guides when you know the task you want to complete.

For exact signatures, columns, and failure conditions, use API Reference, Schema Reference, and Error Reference.

How to Analyze Telemetry

Choose the OTLP reader for the signal you want to analyze:

  • traces: read_otlp_traces(path)
  • logs: read_otlp_logs(path)
  • gauges: read_otlp_metrics_gauge(path)
  • sums and counters: read_otlp_metrics_sum(path)
  • histograms: read_otlp_metrics_histogram(path)
  • exponential histograms: read_otlp_metrics_exp_histogram(path)

If you use the duckdb-otlp server, the server writes incoming telemetry into regular tables such as otlp_traces, otlp_logs, and otlp_metrics_gauge. Use the SQL patterns below with your table name in place of the read_otlp_*('...') call.

The examples use JSONL paths such as traces/*.jsonl. The same readers accept OTLP JSON and protobuf files. For columns and types, use the Schema Reference.

Traces

Find slow server operations:

SELECT
  name,
  service_name,
  count(*) AS span_count,
  avg(duration_time_unix_nano) / 1000000 AS avg_ms,
  percentile_cont(0.95) WITHIN GROUP (ORDER BY duration_time_unix_nano) / 1000000 AS p95_ms
FROM read_otlp_traces('traces/*.jsonl')
WHERE kind = 2
GROUP BY name, service_name
ORDER BY p95_ms DESC
LIMIT 20;

Drill into the slowest trace:

WITH target AS (
  SELECT trace_id
  FROM read_otlp_traces('traces/*.jsonl')
  ORDER BY duration_time_unix_nano DESC
  LIMIT 1
)
SELECT span_id, parent_span_id, service_name, name, duration_time_unix_nano / 1000000 AS duration_ms
FROM read_otlp_traces('traces/*.jsonl')
WHERE trace_id = (SELECT trace_id FROM target)
ORDER BY start_time_unix_nano;

See Traces Schema for span fields, status codes, attributes, events, and links.

Logs

Find recent errors:

SELECT time_unix_nano, service_name, severity_text, body
FROM read_otlp_logs('logs/*.jsonl')
WHERE severity_text IN ('ERROR', 'FATAL')
ORDER BY time_unix_nano DESC
LIMIT 100;

Join error logs back to spans:

SELECT
  l.time_unix_nano,
  l.service_name,
  l.body,
  t.name,
  t.duration_time_unix_nano / 1000000 AS duration_ms
FROM read_otlp_logs('logs/*.jsonl') l
JOIN read_otlp_traces('traces/*.jsonl') t
  ON l.trace_id = t.trace_id
 AND l.span_id = t.span_id
WHERE l.severity_text = 'ERROR'
ORDER BY l.time_unix_nano DESC;

See Logs Schema for severity, body, resource attributes, scope fields, and trace correlation columns.

Metrics

Aggregate gauge metrics over time:

SELECT
  date_trunc('hour', time_unix_nano) AS hour,
  service_name,
  name,
  avg(coalesce(double_value, int_value::DOUBLE)) AS avg_value,
  max(coalesce(double_value, int_value::DOUBLE)) AS max_value
FROM read_otlp_metrics_gauge('metrics/*.jsonl')
WHERE name = 'system.cpu.utilization'
GROUP BY hour, service_name, name
ORDER BY hour DESC;

Inspect histogram metrics:

SELECT
  time_unix_nano,
  service_name,
  name,
  count,
  sum,
  bucket_counts,
  explicit_bounds
FROM read_otlp_metrics_histogram('metrics/*.jsonl')
WHERE name = 'http.server.duration'
ORDER BY time_unix_nano DESC
LIMIT 50;

Metric shapes use different columns. Choose the shape-specific reader, then see Metrics Schema for gauge, sum, histogram, and exponential histogram fields.

Attributes

The readers expose resource, scope, and signal attributes as JSON strings. Use DuckDB JSON functions to filter nested keys:

SELECT time_unix_nano, service_name, body
FROM read_otlp_logs('logs/*.jsonl')
WHERE json_extract_string(resource_attributes, '$."deployment.environment"') = 'prod';

For malformed files or unexpected parse errors, see the Error Reference.

How to Stream OTLP to Local DuckLake

Use the duckdb-otlp Docker image in local-ducklake mode to stream OTLP/HTTP exports into a local DuckLake lakehouse.

The container initializes DuckDB, loads the required extensions, attaches DuckLake, starts the ingest server, and commits accepted rows in batches.

Live ingestion uses OTLP/HTTP on port 4318. WASM builds do not include the ingest server.

Configure

Create .env:

DUCKDB_MODE=local-ducklake
DUCKDB_OTLP_TOKEN=dev-token-123456

DUCKDB_CATALOG=lake
DUCKLAKE_CATALOG_PATH=/data/ducklake/catalog.duckdb
DUCKLAKE_DATA_PATH=/data/ducklake/storage

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

DUCKLAKE_CATALOG_PATH stores DuckLake metadata. DUCKLAKE_DATA_PATH stores Parquet data files.

Start the server

Prefer to run manually in the DuckDB shell? See Run manually.

mkdir -p data

docker run --rm --name duckdb-otlp \
  --env-file .env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v "$(pwd)/data:/data" \
  ghcr.io/smithclay/duckdb-otlp:latest

The container creates the target tables in lake.main if they do not exist:

  • otlp_logs
  • otlp_traces
  • otlp_metrics_gauge
  • otlp_metrics_sum
  • otlp_metrics_histogram
  • otlp_metrics_exp_histogram

Leave the container running while clients send OTLP/HTTP requests.

POST a log record

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer dev-token-123456' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"local-ducklake-demo"}},{"key":"deployment.environment","value":{"stringValue":"docs"}}]},"scopeLogs":[{"scope":{"name":"duckdb-otlp-guide"},"logRecords":[{"timeUnixNano":"1704067200000000000","observedTimeUnixNano":"1704067200123456789","severityNumber":9,"severityText":"INFO","body":{"stringValue":"hello from local DuckLake"},"attributes":[{"key":"guide","value":{"stringValue":"stream-to-local-ducklake"}}]}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

Rows are accepted before they are durable. They commit automatically in the background, on graceful shutdown, or immediately after an explicit flush.

Query committed rows

Flush and query through Quack from a host DuckDB process. The server process owns the DuckLake catalog while it runs, and the distroless image has no shell or bundled DuckDB CLI.

The server image is distroless and has no shell or DuckDB CLI, so do not use docker exec ... sh -c for inspection SQL. The examples in this guide enable Quack, publish port 9494, and use DuckDB 2.0’s CONNECT statement for ordinary server-side SQL. Replace <fingerprint> with the TLS certificate fingerprint the container prints at startup (see Query with Quack).

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>');
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

SELECT time_unix_nano, service_name, severity_text, body
FROM lake.main.otlp_logs
WHERE service_name = 'local-ducklake-demo'
ORDER BY time_unix_nano DESC
LIMIT 5;

DISCONNECT;
SQL

Stop cleanly

docker stop duckdb-otlp

The image sends otlp_stop('otlp:0.0.0.0:4318') during shutdown, so remaining buffered rows are committed before the process exits.

otlp_flush seals buffered ingest rows. Run DuckDB or DuckLake maintenance commands when you need compaction.

Run manually

To run this configuration in a DuckDB 2.0+ shell instead of the daemon, execute the SQL below. Replace bracketed values with the corresponding values from this guide. Keep the shell open while clients send telemetry.

mkdir -p data/ducklake/storage
duckdb data/duckdb-otlp-control.duckdb
-- The daemon embeds otlp statically; the shell loads the extension explicitly.
INSTALL otlp FROM community;
LOAD otlp;

-- Attach the local DuckLake catalog used by the Docker guide.
INSTALL ducklake;
LOAD ducklake;
ATTACH 'ducklake:data/ducklake/catalog.duckdb' AS lake (
  DATA_PATH 'data/ducklake/storage'
);

-- Create the target schema before starting ingestion.
CREATE SCHEMA IF NOT EXISTS lake.main;

-- Match the daemon's default-catalog setting for unqualified queries.
USE lake;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := 'lake',
  schema := 'main',
  token := 'dev-token-123456',
  allow_other_hostname := true
);

-- The guide's daemon configuration also enables Quack.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

Before closing DuckDB, stop both listeners cleanly:

-- Stop Quack, then commit buffered telemetry and stop OTLP.
CALL quack_stop('quack:0.0.0.0:9494');
SELECT status, dropped_rows
FROM otlp_stop('otlp:0.0.0.0:4318');

See also

Query with Quack

Run the duckdb-otlp Docker image in local-ducklake mode, enable the image’s Quack server, and connect to it from a DuckDB process outside Docker.

Use this setup when you want the container to handle ingestion and DuckLake writes while a local DuckDB shell, notebook, or script queries telemetry through Quack.

Quack is stable as of DuckDB 2.0. These examples use its CONNECT statement. The container binds Quack to 0.0.0.0, and on any non-loopback bind Quack serves TLS, with a self-signed certificate unless you supply one. Clients pin that certificate by its fingerprint.

Configure

Create .env:

DUCKDB_MODE=local-ducklake
DUCKDB_OTLP_TOKEN=dev-token-123456

DUCKDB_CATALOG=lake

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

DUCKDB_OTLP_TOKEN protects OTLP/HTTP ingest on port 4318. DUCKDB_QUACK_TOKEN protects DuckDB query access on port 9494.

Quack generates its self-signed certificate on first start and keeps it on the data volume, under /data/.duckdb/extension_data/quack. A redeployed container that mounts the same /data volume keeps the same fingerprint, so pinned clients keep working. A fresh volume gets a new certificate. To use a certificate from your own CA instead, set:

DUCKDB_QUACK_SSL_CERT_FILE=/certs/quack.pem
DUCKDB_QUACK_SSL_KEY_FILE=/certs/quack.key

Local DuckLake mode uses DUCKLAKE_CATALOG_PATH=/data/ducklake/catalog.duckdb and DUCKLAKE_DATA_PATH=/data/ducklake/storage by default. Set those variables when you want DuckLake metadata or Parquet files somewhere else inside the mounted /data volume.

Start the server

Prefer to run the same services manually in the DuckDB shell? See Run manually.

mkdir -p data

docker run --rm --name duckdb-otlp \
  --env-file .env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v "$(pwd)/data:/data" \
  ghcr.io/smithclay/duckdb-otlp:latest

The container initializes DuckLake, starts the OTLP/HTTP ingest server, and starts Quack in the same DuckDB process. The server names the catalog lake and makes it the default catalog Quack exposes, so attached clients reach the signal tables (otlp_logs, otlp_traces, …) directly instead of through a fully qualified lake.main.* name.

Once Quack is up, the container prints how to reach it, including the certificate fingerprint:

Query over Quack at https://0.0.0.0:9494
TLS certificate SHA-256 fingerprint: 3D:2C:B0:...:4F:8F
  ATTACH 'quack:127.0.0.1:9494' AS otel (TYPE quack, SSL_FINGERPRINT '3D:2C:B0:...:4F:8F');

Run docker logs duckdb-otlp to see it again. Leave the container running while clients send OTLP/HTTP requests and local DuckDB clients query through Quack.

POST a log record

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer dev-token-123456' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"quack-local-ducklake-demo"}},{"key":"deployment.environment","value":{"stringValue":"docs"}}]},"scopeLogs":[{"scope":{"name":"duckdb-otlp-guide"},"logRecords":[{"timeUnixNano":"1704067200000000000","observedTimeUnixNano":"1704067200123456789","severityNumber":9,"severityText":"INFO","body":{"stringValue":"hello from local DuckDB over Quack"},"attributes":[{"key":"guide","value":{"stringValue":"query-with-quack"}}]}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

Rows are accepted before they are durable. They commit automatically in the background, on graceful shutdown, or immediately after an explicit flush.

Connect from local DuckDB

In another terminal, start the DuckDB CLI on your host machine:

duckdb

Install and load Quack in the local DuckDB process:

INSTALL quack;
LOAD quack;

Create a Quack secret scoped to the container endpoint, attach the remote DuckDB process with the fingerprint the container printed, then connect the session to it:

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>');
CONNECT otel;

SSL_FINGERPRINT makes the client use TLS and accept only that certificate. Without it, a localhost client tries plain HTTP and fails with Unsupported protocol error. The Docker port mapping forwards local port 9494 to quack:0.0.0.0:9494 inside the container.

The same ATTACH works from a remote host. With a certificate from a CA your clients trust, drop SSL_FINGERPRINT. A tunneling extension such as Query-farm/quackscale keeps the Quack listener off the public network.

Query telemetry with CONNECT

After CONNECT otel, DuckDB routes ordinary SQL to the container’s DuckDB process and streams results back. The daemon makes its telemetry catalog (named lake here) the default, so the signal tables — otlp_logs, otlp_traces, otlp_metrics_gauge, otlp_metrics_sum, otlp_metrics_histogram, otlp_metrics_exp_histogram — are reachable by their plain names.

The server accepts rows before it makes them durable. For a short local test, flush the ingest buffer first:

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

Then query the signal tables directly:

SELECT time_unix_nano, service_name, severity_text, body
FROM otlp_logs
WHERE service_name = 'quack-local-ducklake-demo'
ORDER BY time_unix_nano DESC
LIMIT 5;

The same works for traces:

SELECT trace_id, name, service_name, duration_time_unix_nano
FROM otlp_traces
ORDER BY start_time_unix_nano DESC
LIMIT 20;

Run server-side SQL

While connected, aggregations, DDL, and table functions run in the server session without SQL-in-a-string wrapping:

SELECT service_name, count(*) AS rows
FROM otlp_logs
GROUP BY ALL
ORDER BY rows DESC;

Use quack_query for a one-shot call without a connected session, for example in small automation scripts:

FROM quack_query(
  'quack:localhost:9494',
  'SELECT service_name, count(*) AS rows FROM otlp_logs GROUP BY ALL ORDER BY rows DESC',
  token := 'dev-quack-token-123456',
  ssl_fingerprint := '<fingerprint>'
);

When you are done with the interactive remote session, disconnect it:

DISCONNECT;

Stop cleanly

docker stop duckdb-otlp

The image sends otlp_stop('otlp:0.0.0.0:4318') during shutdown, so remaining buffered rows are committed before the process exits.

Run manually

To run this configuration in a DuckDB 2.0+ shell instead of the daemon, execute the SQL below. Replace bracketed values with the corresponding values from this guide. Keep the shell open while clients send telemetry.

mkdir -p data/ducklake/storage
duckdb data/duckdb-otlp-control.duckdb
-- The daemon embeds otlp statically; the shell loads the extension explicitly.
INSTALL otlp FROM community;
LOAD otlp;

-- Attach the local DuckLake catalog used by the Docker guide.
INSTALL ducklake;
LOAD ducklake;
ATTACH 'ducklake:data/ducklake/catalog.duckdb' AS lake (
  DATA_PATH 'data/ducklake/storage'
);

-- Create the target schema before starting ingestion.
CREATE SCHEMA IF NOT EXISTS lake.main;

-- Match the daemon's default-catalog setting for unqualified queries.
USE lake;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := 'lake',
  schema := 'main',
  token := 'dev-token-123456',
  allow_other_hostname := true
);

-- The guide's daemon configuration also enables Quack.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

-- The fingerprint clients pin: Quack serves TLS on this non-loopback bind.
SELECT info['ssl_fingerprint'] FROM quack_server_list();

Before closing DuckDB, stop both listeners cleanly:

-- Stop Quack, then commit buffered telemetry and stop OTLP.
CALL quack_stop('quack:0.0.0.0:9494');
SELECT status, dropped_rows
FROM otlp_stop('otlp:0.0.0.0:4318');

Clean up

After you stop the container, remove the local DuckLake files if you no longer need them:

rm -rf data

How to Stream OTLP to Remote DuckLake

Use the duckdb-otlp Docker image in r2-neon-ducklake mode to stream OTLP/HTTP exports into DuckLake with a Neon Postgres catalog and Cloudflare R2 data files.

The container initializes DuckDB, loads the required extensions, connects DuckLake to Neon, stores Parquet files in R2, starts the ingest server, and commits accepted rows in batches.

Live ingestion uses OTLP/HTTP on port 4318. WASM builds do not include the ingest server.

For Google Cloud Storage and Cloud SQL, use Stream to DuckLake on GCP.

Prepare Neon and R2

Create or choose a Neon database for the DuckLake catalog. Copy the connection details from Neon as separate values:

  • host
  • port
  • database
  • user
  • password
  • SSL mode

Create or choose a Cloudflare R2 bucket for DuckLake data files:

export CLOUDFLARE_ACCOUNT_ID=<account-id>
export R2_BUCKET=duckdb-otlp-ducklake

wrangler r2 bucket create "$R2_BUCKET"

Create an R2 S3-compatible access key pair that can write objects to the bucket. Save the access key ID and secret access key for the next step.

Configure

Create remote-ducklake.env:

DUCKDB_MODE=r2-neon-ducklake
DUCKDB_OTLP_TOKEN=dev-token-123456

DUCKDB_CATALOG=lake
DUCKDB_SCHEMA=otlp

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

CLOUDFLARE_ACCOUNT_ID=<account-id>
R2_BUCKET=<bucket-name>
R2_PREFIX=duckdb-otlp/
R2_ACCESS_KEY_ID=<r2-s3-access-key-id>
R2_SECRET_ACCESS_KEY=<r2-s3-secret-access-key>

PGHOST=<neon-host>
PGPORT=5432
PGDATABASE=<database>
PGUSER=<user>
PGPASSWORD=<password>
PGSSLMODE=require

If you use a custom R2 endpoint, add R2_ENDPOINT=<endpoint-host>.

Start the server

Prefer to run manually in the DuckDB shell? See Run manually.

docker run --rm --name duckdb-otlp \
  --env-file remote-ducklake.env \
  -p 4318:4318 \
  -p 9494:9494 \
  ghcr.io/smithclay/duckdb-otlp:latest

The container creates the target tables in lake.otlp if they do not exist:

  • otlp_logs
  • otlp_traces
  • otlp_metrics_gauge
  • otlp_metrics_sum
  • otlp_metrics_histogram
  • otlp_metrics_exp_histogram

Leave the container running while clients send OTLP/HTTP requests.

POST a log record

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer dev-token-123456' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"remote-ducklake-demo"}},{"key":"deployment.environment","value":{"stringValue":"docs"}}]},"scopeLogs":[{"scope":{"name":"duckdb-otlp-guide"},"logRecords":[{"timeUnixNano":"1704067200000000000","observedTimeUnixNano":"1704067200123456789","severityNumber":9,"severityText":"INFO","body":{"stringValue":"hello from remote DuckLake"},"attributes":[{"key":"guide","value":{"stringValue":"stream-to-remote-ducklake"}}]}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

Rows are accepted before they are durable. They commit automatically in the background, on graceful shutdown, or immediately after an explicit flush.

Query committed rows

Flush and query through Quack from a host DuckDB process. The server process owns the DuckLake catalog connection while it runs, and the distroless image has no shell or bundled DuckDB CLI.

The server image is distroless and has no shell or DuckDB CLI, so do not use docker exec ... sh -c for inspection SQL. The examples in this guide enable Quack, publish port 9494, and use DuckDB 2.0’s CONNECT statement for ordinary server-side SQL. Replace <fingerprint> with the TLS certificate fingerprint the container prints at startup (see Query with Quack).

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>');
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

SELECT service_name, severity_text, body
FROM lake.otlp.otlp_logs
WHERE service_name = 'remote-ducklake-demo'
ORDER BY time_unix_nano DESC
LIMIT 5;

DISCONNECT;
SQL

Stop cleanly

If you plan to delete the Neon and R2 resources immediately, skip this step and use Clean up instead.

docker stop duckdb-otlp

The image sends otlp_stop('otlp:0.0.0.0:4318') during shutdown, so remaining buffered rows are committed before the process exits.

Clean up

Drop the DuckLake tables before deleting the Neon database or R2 bucket:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT status FROM otlp_stop('otlp:0.0.0.0:4318');
DROP TABLE IF EXISTS lake.otlp.otlp_logs;
DROP TABLE IF EXISTS lake.otlp.otlp_traces;
DROP TABLE IF EXISTS lake.otlp.otlp_metrics_gauge;
DROP TABLE IF EXISTS lake.otlp.otlp_metrics_sum;
DROP TABLE IF EXISTS lake.otlp.otlp_metrics_histogram;
DROP TABLE IF EXISTS lake.otlp.otlp_metrics_exp_histogram;
DETACH lake;

DISCONNECT;
SQL

docker stop duckdb-otlp

Then delete the R2 prefix or bucket and remove the Neon database or branch you created for this guide.

Run manually

To run this configuration in a DuckDB 2.0+ shell instead of the daemon, execute the SQL below. Replace bracketed values with the corresponding values from this guide. Keep the shell open while clients send telemetry.

duckdb duckdb-otlp-control.duckdb
-- The daemon embeds otlp statically; the shell loads the extension explicitly.
INSTALL otlp FROM community;
LOAD otlp;

-- Configure R2 storage and the Neon-backed DuckLake catalog.
INSTALL ducklake;
INSTALL postgres;
INSTALL httpfs;
LOAD ducklake;
LOAD postgres;
LOAD httpfs;
CREATE OR REPLACE SECRET r2_storage (
  TYPE s3,
  KEY_ID '<r2-s3-access-key-id>',
  SECRET '<r2-s3-secret-access-key>',
  REGION 'auto',
  ENDPOINT '<account-id>.r2.cloudflarestorage.com',
  URL_STYLE 'path'
);
CREATE OR REPLACE SECRET postgres_secret (
  TYPE postgres,
  HOST '<neon-host>',
  PORT 5432,
  DATABASE '<database>',
  USER '<user>',
  PASSWORD '<password>',
  SSLMODE 'require'
);
CREATE OR REPLACE SECRET ducklake_secret (
  TYPE ducklake,
  METADATA_PATH '',
  DATA_PATH 's3://<bucket-name>/duckdb-otlp/',
  METADATA_PARAMETERS MAP {'TYPE': 'postgres', 'SECRET': 'postgres_secret'}
);
ATTACH 'ducklake:ducklake_secret' AS lake;

-- Create the target schema before starting ingestion.
CREATE SCHEMA IF NOT EXISTS lake.otlp;

-- Match the daemon's default-catalog setting for unqualified queries.
USE lake;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := 'lake',
  schema := 'otlp',
  token := 'dev-token-123456',
  allow_other_hostname := true
);

-- The guide's daemon configuration also enables Quack.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

Before closing DuckDB, stop both listeners cleanly:

-- Stop Quack, then commit buffered telemetry and stop OTLP.
CALL quack_stop('quack:0.0.0.0:9494');
SELECT status, dropped_rows
FROM otlp_stop('otlp:0.0.0.0:4318');

Troubleshooting

  • If the container cannot connect to Neon at startup, confirm PGHOST, PGDATABASE, PGUSER, PGPASSWORD, and PGSSLMODE=require.
  • If the container connects to Neon but cannot write data files, confirm the R2 access key can write objects to R2_BUCKET.
  • If R2 paths use the wrong location, confirm CLOUDFLARE_ACCOUNT_ID, R2_BUCKET, and R2_PREFIX.
  • If no rows appear after a 202 response, run the flush command before querying.
  • otlp_flush seals buffered ingest rows. Run DuckDB or DuckLake maintenance commands when you need compaction.

See also

How to Stream OTLP to DuckLake on GCP

Use DUCKDB_MODE=gcp-ducklake to store DuckLake metadata in PostgreSQL and Parquet data in Google Cloud Storage. Cloud SQL can host the catalog in a new database on an existing instance. The daemon uses the native gcs extension with Application Default Credentials (ADC), so no GCS HMAC keys are needed.

Prepare storage and access

  • Create a dedicated GCS bucket or prefix for the lake.
  • Give the receiver’s service account roles/storage.objectAdmin on that bucket. DuckLake maintenance needs list and delete access as well as read and write.
  • Create a PostgreSQL database and a dedicated catalog user. Grant CONNECT on the database and USAGE, CREATE on its public schema; DuckLake creates and manages its own metadata tables.
  • Make PostgreSQL reachable from the receiver. For Cloud SQL, use a Cloud SQL Auth Proxy socket mounted into the container, or a reachable TCP endpoint with the appropriate TLS configuration. The image does not start a proxy itself.

On a GCP VM, attach the service account and enable the cloud-platform OAuth scope; bucket IAM determines storage access. A proxy also needs the roles/cloudsql.client role. In a local container, mount an ADC credential file readable by uid 65532 and set GOOGLE_APPLICATION_CREDENTIALS to its container path. Credentials on the host are not automatically available inside Docker.

The image includes the system CA bundle and the compatibility path needed by the GCS extension for TLS verification; no CA certificate mount is required. On Cloud Run, use an attached service account for ADC rather than mounting a credential file or setting GOOGLE_APPLICATION_CREDENTIALS.

Configure

Create gcp-ducklake.env with permissions restricted to its owner:

DUCKDB_MODE=gcp-ducklake
DUCKDB_OTLP_TOKEN=<private-token-at-least-16-characters>
DUCKDB_CATALOG=lake
DUCKDB_SCHEMA=otlp
DUCKLAKE_DATA_PATH=gcss://your-trace-bucket/ducklake/

PGHOST=/cloudsql/your-project:us-central1:your-instance
PGPORT=5432
PGDATABASE=tracelake
PGUSER=tracelake_catalog
PGPASSWORD=<catalog-user-password>
PGSSLMODE=disable

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=<separate-private-admin-token>

PGHOST, PGDATABASE, PGUSER, PGPASSWORD, and DUCKLAKE_DATA_PATH are required. PGPORT defaults to 5432; PGSSLMODE defaults to require. The disable value above is only for the local Unix socket hop to a Cloud SQL Auth Proxy, which provides the encrypted connection to Cloud SQL. These are ordinary PostgreSQL connection settings; the mode is not tied to Cloud SQL. It does not acquire or refresh PostgreSQL IAM tokens.

The data path must use gcss:// to select the native GCS filesystem even if httpfs is loaded. GCS auth uses ADC independently of the PostgreSQL password.

The image loads a patched gcs extension (smithclay/duckdb-gcs) through DUCKDB_OTLP_GCS_EXTENSION_PATH. The community build prints a failed upload finalize instead of raising it, so DuckLake commits data files that were never written (#90). Outside the image, unset that variable to use the community build, or point it at your own gcs.duckdb_extension.

Warning

Neither the patched nor the community gcs extension has a DuckDB 2.0 build yet, so gcp-ducklake fails at startup on the current image, naming the missing extension.

Run and verify

On a GCP VM with its service account attached and a running proxy writing sockets under /cloudsql:

docker run --rm --name duckdb-otlp \
  --env-file gcp-ducklake.env \
  --mount type=bind,src=/cloudsql,dst=/cloudsql \
  -p 127.0.0.1:4318:4318 \
  -p 127.0.0.1:9494:9494 \
  ghcr.io/smithclay/duckdb-otlp:latest

Use a pinned image digest for deployed services. Both host ports bind to loopback in this example. Put the ingest endpoint behind HTTPS for remote producers and keep Quack private: it provides full SQL access. The proxy directory and sockets must be accessible to the image’s nonroot uid 65532. Bind-mounted /data, if used, must also be writable by that uid.

The daemon creates the OTLP tables in lake.otlp. Send a record with the ingest token from your environment file:

POST a log record

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer <private-token-at-least-16-characters>' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"gcp-demo"}},{"key":"deployment.environment","value":{"stringValue":"docs"}}]},"scopeLogs":[{"scope":{"name":"duckdb-otlp-guide"},"logRecords":[{"timeUnixNano":"1704067200000000000","observedTimeUnixNano":"1704067200123456789","severityNumber":9,"severityText":"INFO","body":{"stringValue":"hello from GCP DuckLake"},"attributes":[{"key":"guide","value":{"stringValue":"stream-to-gcp-ducklake"}}]}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

Rows are accepted before they are durable. They commit automatically in the background, on graceful shutdown, or immediately after an explicit flush.

Query committed rows

Flush and query through Quack from a host DuckDB process:

The server image is distroless and has no shell or DuckDB CLI, so do not use docker exec ... sh -c for inspection SQL. The examples in this guide enable Quack, publish port 9494, and use DuckDB 2.0’s CONNECT statement for ordinary server-side SQL. Replace <fingerprint> with the TLS certificate fingerprint the container prints at startup (see Query with Quack).

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN '<separate-private-admin-token>'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>');
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

SELECT service_name, severity_text, body
FROM lake.otlp.otlp_logs
WHERE service_name = 'gcp-demo'
ORDER BY time_unix_nano DESC
LIMIT 5;

DISCONNECT;
SQL

Stop cleanly

docker stop duckdb-otlp

The image sends otlp_stop('otlp:0.0.0.0:4318') during shutdown, so remaining buffered rows are committed before the process exits.

For traces, send OTLP/HTTP protobuf or JSON to /v1/traces, then query lake.otlp.otlp_traces. Configure exporters with the HTTPS endpoint and Authorization: Bearer <ingest-token>.

Operate the lake

A successful ingest response means buffered in memory. A crash can lose rows accepted since the last commit; graceful shutdown flushes them. PostgreSQL-backed DuckLake supports concurrent appenders, including overlap during a deployment. Each receiver must use its own local control database; share the remote catalog and GCS data path, not a local DuckDB file. Bootstrap the catalog/tables once before scaling out, since concurrent schema creation can conflict. See DuckLake conflict resolution.

On Cloud Run, enable instance-based billing (cpu_idle = false) for background commits and keep a minimum of one instance for prompt ingestion. Configure the container port as 4318. Cloud Run supplies HTTPS; make sure its ingress and invoker policy admit your producers before the daemon validates their bearer token. Configure Cloud SQL socket mounting and the receiver service account as above, and keep Quack unexposed. Monitor commit failures and test a rolling deployment before increasing the instance limit. See the live ingest reference for buffer limits, commit health, and maintenance settings.

DuckLake snapshot/file maintenance does not impose a trace retention period. Delete expired rows through DuckLake before expiring snapshots and cleaning unused files. Do not let bucket lifecycle rules delete files still referenced by the catalog.

Small commits are inlined into the PostgreSQL catalog until a DuckLake CHECKPOINT flushes them to Parquet in GCS; the daemon runs one every 5 minutes (maintenance_interval_ms) while rows are being committed and prints each outcome (catalog maintenance checkpoint succeeded / WARNING: catalog maintenance checkpoint failed ...) to stderr, so alert on the warning. Set DUCKLAKE_DATA_INLINING_ROW_LIMIT=0 to write Parquet on every commit instead.

If startup fails, check PostgreSQL connectivity and grants, ADC availability in the container, and bucket IAM. If ingestion succeeds but rows do not appear, inspect commit errors with otlp_server_list() through private Quack access.

How to Store Claude Code or Codex Traces in Local DuckLake

Run the duckdb-otlp server image locally and point Claude Code or Codex at it with OTLP/HTTP. The container listens on localhost:4318 and writes traces into a DuckLake catalog stored in a Docker volume.

The examples follow the Claude Code monitoring docs and the Codex observability and configuration docs.

Start the Local Writer

Prefer to run manually in the DuckDB shell? See Run manually.

Create a Docker volume for DuckLake metadata and Parquet data:

docker volume create duckdb-otlp-ducklake

Create .env:

DUCKDB_MODE=local-ducklake
DUCKDB_CATALOG=lake
DUCKDB_OTLP_TOKEN=dev-otlp-token-123456

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

Start the published server image:

docker run --rm --name duckdb-otlp \
  --env-file .env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v duckdb-otlp-ducklake:/data \
  ghcr.io/smithclay/duckdb-otlp:latest

This starts duckdb-otlp at http://localhost:4318. Send OTLP/HTTP traces to:

http://localhost:4318/v1/traces

The token in .env is:

dev-otlp-token-123456

To use a different local token, change DUCKDB_OTLP_TOKEN and use the same value in the agent exporter headers.

Export Claude Code Traces

Run Claude Code with tracing enabled and route spans to the local writer:

# To make this apply to every Claude Code session, add these to ~/.claude/settings.json
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces
export OTEL_EXPORTER_OTLP_HEADERS='Authorization=Bearer dev-otlp-token-123456'

claude -p "write one sentence about local trace storage"

To store Claude Code events in DuckLake, add the logs exporter before starting Claude Code:

export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4318/v1/logs

Leave OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, OTEL_LOG_TOOL_CONTENT, and OTEL_LOG_RAW_API_BODIES unset unless you intend to store prompt text, tool details, tool content, or raw API bodies.

Export Codex Traces

Put telemetry routing in your user-level Codex config. Codex ignores otel in project-local .codex/config.toml.

Edit ~/.codex/config.toml:

[otel]
environment = "local"
log_user_prompt = false
metrics_exporter = "none"
exporter = { otlp-http = {
  endpoint = "http://localhost:4318/v1/logs",
  protocol = "binary",
  headers = { "Authorization" = "Bearer dev-otlp-token-123456" }
}}
trace_exporter = { otlp-http = {
  endpoint = "http://localhost:4318/v1/traces",
  protocol = "binary",
  headers = { "Authorization" = "Bearer dev-otlp-token-123456" }
}}

Start a new Codex process after editing the config:

codex exec "write one sentence about local trace storage"

To collect spans without Codex event logs, set exporter = "none" and keep the trace_exporter block.

Flush Buffered Telemetry

duckdb-otlp buffers accepted rows. Flush before you query a short local run:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

DISCONNECT;
SQL

Inspect Stored Traces

Query through the running DuckDB process with Quack. The server process owns the DuckLake catalog lock while it runs, and the distroless image has no shell or bundled DuckDB CLI, so do not use docker exec ... sh -c for inspection SQL.

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT trace_id, name, service_name, duration_time_unix_nano
FROM lake.main.otlp_traces
ORDER BY start_time_unix_nano DESC
LIMIT 20;

DISCONNECT;
SQL

If you enabled event logs, inspect recent log rows:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT time_unix_nano, service_name, severity_text, body
FROM lake.main.otlp_logs
ORDER BY time_unix_nano DESC
LIMIT 20;

DISCONNECT;
SQL

Stop the Writer

Stop the container with Ctrl-C if your terminal is attached, or run:

docker stop duckdb-otlp

During shutdown, the image sends otlp_stop('otlp:0.0.0.0:4318') to DuckDB so the process commits remaining buffered rows before it exits.

Run manually

To run this configuration in a DuckDB 2.0+ shell instead of the daemon, create the local DuckLake directories and open a control database:

mkdir -p data/ducklake/storage
duckdb data/duckdb-otlp-control.duckdb

Then execute the same setup and server commands used by the guide’s daemon configuration. The daemon embeds otlp statically; the shell loads it explicitly.

-- Load the extensions and attach the local DuckLake catalog.
INSTALL otlp FROM community;
LOAD otlp;
INSTALL ducklake;
LOAD ducklake;
ATTACH 'ducklake:data/ducklake/catalog.duckdb' AS lake (
  DATA_PATH 'data/ducklake/storage'
);

-- Create the target schema and make its catalog the default.
CREATE SCHEMA IF NOT EXISTS lake.main;
USE lake;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := 'lake',
  schema := 'main',
  token := 'dev-otlp-token-123456',
  allow_other_hostname := true
);

-- This guide also enables Quack for inspection from another DuckDB process.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

Keep the shell open while the agents send telemetry. Before closing it, stop both listeners cleanly:

CALL quack_stop('quack:0.0.0.0:9494');
SELECT status, dropped_rows
FROM otlp_stop('otlp:0.0.0.0:4318');

If No Traces Appear

  • Start the agent process after you set the telemetry settings.
  • Confirm the trace endpoint is http://localhost:4318/v1/traces.
  • Confirm the Authorization header uses the same token as DUCKDB_OTLP_TOKEN.
  • Flush the writer before querying short sessions.
  • Keep the query window recent enough to include the agent run.

How to Stream OTLP to Parquet

Use the duckdb-otlp Docker image in parquet mode to stream OTLP/HTTP exports into partitioned Parquet files.

Use this when you want ordinary DuckDB-readable files instead of a lakehouse catalog. The Parquet dataset is the only durable store — the daemon keeps no local copy of the data. Each seal writes the buffered rows to the configured Parquet root:

<export-root>/<table>/year=YYYY/month=MM/day=DD/*.parquet

PARQUET_EXPORT_PATH can be a local path such as /data/otlp-parquet or a DuckDB-writable URI such as s3://bucket/prefix.

Live ingestion uses OTLP/HTTP on port 4318. WASM builds do not include the ingest server.

Warning

Parquet export is at-least-once

A Parquet COPY is a file write, not a catalog transaction, so it cannot be rolled back. The server never re-writes a signal that already exported, but if a single seal’s COPY fails part-way through (for example a transient S3 error) the next attempt re-exports that signal’s rows, leaving duplicates under the same partition. Deduplicate downstream (for example by a unique attribute) if you need exactly-once semantics. For transactional, exactly-once ingest use a DuckLake or catalog mode instead.

Configure local Parquet

Create parquet.env:

DUCKDB_MODE=parquet
DUCKDB_OTLP_TOKEN=dev-token-123456
DUCKDB_SCHEMA=otlp

PARQUET_EXPORT_PATH=/data/otlp-parquet

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

If you omit PARQUET_EXPORT_PATH, the daemon writes to /data/parquet.

Configure S3 Parquet

For S3, set PARQUET_EXPORT_PATH to an s3:// URI and provide AWS credentials through DuckDB’s credential chain:

DUCKDB_MODE=parquet
DUCKDB_OTLP_TOKEN=dev-token-123456
DUCKDB_SCHEMA=otlp

PARQUET_EXPORT_PATH=s3://duckdb-otlp-telemetry/otlp
AWS_REGION=us-west-2
AWS_PROFILE=cli-dev

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

You can also use S3_BUCKET and S3_PREFIX instead of PARQUET_EXPORT_PATH; those resolve to s3://$S3_BUCKET/$S3_PREFIX.

Start the server

Prefer to run manually in the DuckDB shell? See Run manually.

For local Parquet output:

mkdir -p data

docker run --rm --name duckdb-otlp \
  --env-file parquet.env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v "$(pwd)/data:/data" \
  ghcr.io/smithclay/duckdb-otlp:latest

For S3 output, mount your AWS config read-only:

docker run --rm --name duckdb-otlp \
  --env-file parquet.env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v "$(pwd)/data:/data" \
  -v "$HOME/.aws:/root/.aws:ro" \
  ghcr.io/smithclay/duckdb-otlp:latest

Each seal writes only to Parquet. For convenient inspection over Quack, the daemon lazily creates a read-only view over the exported files for each signal — otlp.otlp_logs, otlp.otlp_traces, otlp.otlp_metrics_gauge, otlp.otlp_metrics_sum, otlp.otlp_metrics_histogram, otlp.otlp_metrics_exp_histogram. These views read the Parquet dataset directly (so they reflect exactly what is durable, including any at-least-once duplicates) and appear after the first seal for that signal. They store no data. Logs and metrics partition by time_unix_nano; traces partition by start_time_unix_nano.

POST a log record

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer dev-token-123456' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"parquet-demo"}},{"key":"deployment.environment","value":{"stringValue":"docs"}}]},"scopeLogs":[{"scope":{"name":"duckdb-otlp-guide"},"logRecords":[{"timeUnixNano":"1704067200000000000","observedTimeUnixNano":"1704067200123456789","severityNumber":9,"severityText":"INFO","body":{"stringValue":"hello from Parquet mode"},"attributes":[{"key":"guide","value":{"stringValue":"stream-to-parquet"}}]}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

Rows are accepted before they are durable. They commit automatically in the background, on graceful shutdown, or immediately after an explicit flush.

Flush and inspect

Flush through Quack from a local DuckDB process:

duckdb -unsigned -c "
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;
SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');
DISCONNECT;
"

The example log record uses 2024-01-01, so local output lands under this path:

find data/otlp-parquet/otlp_logs/year=2024/month=01/day=01 -name '*.parquet'

For S3 output:

aws s3 ls \
  "s3://duckdb-otlp-telemetry/otlp/otlp_logs/year=2024/month=01/day=01/" \
  --profile cli-dev \
  --region us-west-2 \
  --recursive

To query the exported rows through the inspection view inside the running daemon (this reads the Parquet files, not a local copy). The daemon creates these views only when Quack is enabled, because creating one reads the footer of every file already exported:

duckdb -unsigned -c "
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT time_unix_nano, service_name, severity_text, body
FROM otlp.otlp_logs
WHERE service_name = 'parquet-demo'
ORDER BY time_unix_nano DESC
LIMIT 5;

DISCONNECT;
"

To query local Parquet files directly:

SELECT service_name, severity_text, body
FROM read_parquet(
  'data/otlp-parquet/otlp_logs/**/*.parquet',
  hive_partitioning = true
)
WHERE year = '2024' AND month = '01' AND day = '01';

For S3 Parquet, create an S3 secret first:

INSTALL httpfs;
LOAD httpfs;

CREATE OR REPLACE SECRET plain_s3_secret (
  TYPE s3,
  PROVIDER credential_chain,
  CHAIN config,
  PROFILE 'cli-dev',
  REGION 'us-west-2'
);

SELECT service_name, severity_text, body
FROM read_parquet(
  's3://duckdb-otlp-telemetry/otlp/otlp_logs/**/*.parquet',
  hive_partitioning = true
)
WHERE year = '2024' AND month = '01' AND day = '01';

Stop cleanly

If you plan to delete the Parquet resources immediately, skip this step and use Clean up instead.

docker stop duckdb-otlp

The image sends otlp_stop('otlp:0.0.0.0:4318') during shutdown, so remaining buffered rows are committed before the process exits.

Clean up

For local output:

rm -rf data

For S3 output:

aws s3 rm "s3://duckdb-otlp-telemetry/otlp/" \
  --profile cli-dev \
  --region us-west-2 \
  --recursive

Run manually

To run this configuration in a DuckDB 2.0+ shell instead of the daemon, execute the SQL below. Replace bracketed values with the corresponding values from this guide. Keep the shell open while clients send telemetry.

duckdb duckdb-otlp-control.duckdb

Local Parquet

-- The daemon embeds otlp statically; the shell loads the extension explicitly.
INSTALL otlp FROM community;
LOAD otlp;

-- Local Parquet needs no storage extension setup.

-- Create the target schema before starting ingestion.
CREATE SCHEMA IF NOT EXISTS otlp;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := '',
  schema := 'otlp',
  token := 'dev-token-123456',
  allow_other_hostname := true,
  parquet_export_path := 'data/otlp-parquet'
);

-- The guide's daemon configuration also enables Quack.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

S3 Parquet

Use the profile, region, and export URI configured earlier in this guide.

-- The daemon embeds otlp statically; the shell loads the extension explicitly.
INSTALL otlp FROM community;
LOAD otlp;

-- Configure the AWS credential chain used by the S3 variant.
INSTALL aws;
INSTALL httpfs;
LOAD aws;
LOAD httpfs;
CREATE OR REPLACE SECRET plain_s3_secret (
  TYPE s3,
  PROVIDER credential_chain,
  CHAIN config,
  PROFILE 'cli-dev',
  REGION 'us-west-2'
);

-- Create the target schema before starting ingestion.
CREATE SCHEMA IF NOT EXISTS otlp;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := '',
  schema := 'otlp',
  token := 'dev-token-123456',
  allow_other_hostname := true,
  parquet_export_path := 's3://duckdb-otlp-telemetry/otlp'
);

-- The guide's daemon configuration also enables Quack.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

Before closing DuckDB, stop both listeners cleanly:

-- Stop Quack, then commit buffered telemetry and stop OTLP.
CALL quack_stop('quack:0.0.0.0:9494');
SELECT status, dropped_rows
FROM otlp_stop('otlp:0.0.0.0:4318');

Troubleshooting

  • If S3 startup cannot find credentials, confirm AWS_PROFILE in parquet.env matches a profile in the mounted $HOME/.aws directory.
  • If S3 writes fail, confirm the profile can write objects under PARQUET_EXPORT_PATH.
  • If no files appear after a 202 response, run otlp_flush before listing the output path.
  • Plain Parquet object writes are not catalog transactions (see the at-least-once caution above). A signal that already exported is never re-written, but if a single seal’s COPY fails part-way through and the server retries, that signal’s rows can be duplicated under the same partition. Deduplicate downstream, or use a catalog mode for exactly-once.

See also

How to Stream to Vortex

Convert OpenTelemetry files to Vortex — a compressed, columnar file format with a DuckDB core extension — entirely on your machine. Read OTLP with the read_otlp_* table functions, then COPY straight to a .vortex file. No daemon or catalog required.

This is the file-conversion counterpart to How to stream to Parquet: the same readers, a different output format.

Prerequisites

  • DuckDB 2.0 or later.
  • OTLP files in protobuf, JSON, or NDJSON. The read_otlp_* readers accept all three, plus globs and remote URLs.

Install the extensions

otlp is a community extension and vortex is a DuckDB core extension. Load both in the same session:

INSTALL otlp FROM community;
LOAD otlp;
INSTALL vortex;
LOAD vortex;

For a development build of otlp, start DuckDB with -unsigned and install it from GitHub instead — see Get Started.

Export OTLP to Vortex

Each COPY ... TO '<file>' (FORMAT vortex) writes one query result to one Vortex file. Always pass FORMAT vortex — without it DuckDB writes CSV. Run one COPY per signal you want to keep:

COPY (SELECT * FROM read_otlp_traces('traces.pb'))
  TO 'traces.vortex' (FORMAT vortex);

COPY (SELECT * FROM read_otlp_logs('logs.pb'))
  TO 'logs.vortex' (FORMAT vortex);

COPY (SELECT * FROM read_otlp_metrics_gauge('metrics.pb'))
  TO 'metrics_gauge.vortex' (FORMAT vortex);

Because the readers accept globs, you can fold a directory of NDJSON into a single Vortex file:

COPY (SELECT * FROM read_otlp_logs('logs/*.jsonl'))
  TO 'logs.vortex' (FORMAT vortex);

COPY takes any query, so project or filter first to keep only what you need:

COPY (
  SELECT time_unix_nano, service_name, severity_text, body
  FROM read_otlp_logs('logs.pb')
  WHERE severity_text = 'ERROR'
) TO 'errors.vortex' (FORMAT vortex);

Column types are preserved through the round trip, including TIMESTAMP_NS timestamps. See the Schema Reference for every column each reader emits.

Query the Vortex files

Read them back with read_vortex(). It accepts a single file or a glob:

SELECT trace_id, name, service_name, status_code
FROM read_vortex('traces.vortex');

SELECT service_name, severity_text, body
FROM read_vortex('logs.vortex')
WHERE severity_text = 'ERROR';

-- Read every Vortex file in a directory at once.
SELECT count(*) FROM read_vortex('*.vortex');

Convert an existing Parquet export

If you already produce Parquet — for example from How to stream to Parquet — re-encode it to Vortex without reparsing OTLP:

COPY (
  SELECT * FROM read_parquet(
    'data/otlp-parquet/otlp_traces/**/*.parquet',
    hive_partitioning = true
  )
) TO 'traces.vortex' (FORMAT vortex);

See also

How to Stream OTLP to Amazon S3 Tables

Use the duckdb-otlp Docker image in s3-tables mode to stream OTLP/HTTP exports into an Iceberg catalog hosted by Amazon S3 Tables.

The container initializes DuckDB, loads the required extensions, attaches the S3 Tables table bucket, starts the ingest server, and commits accepted rows in batches.

Choose Amazon S3 Tables when you want AWS-managed table buckets and an Iceberg REST catalog endpoint. To write partitioned Parquet files to a regular s3:// bucket, use Stream to Parquet.

Live ingestion uses OTLP/HTTP on port 4318. WASM builds do not include the ingest server.

Create S3 Tables resources

Choose a region and an AWS CLI profile that can create CloudFormation and S3 Tables resources:

export AWS_PROFILE=cli-dev
export AWS_REGION=us-west-2
export STACK_NAME=duckdb-otlp-s3tables

export AWS_ACCOUNT_ID="$(
  aws sts get-caller-identity \
    --profile "$AWS_PROFILE" \
    --query Account \
    --output text
)"

export TABLE_BUCKET_NAME="duckdb-otlp-s3tables-${AWS_ACCOUNT_ID}-${AWS_REGION}"

If aws sts get-caller-identity fails because your profile expired, refresh that profile first with your normal AWS auth flow, for example aws sso login --profile "$AWS_PROFILE" for SSO profiles.

Save this CloudFormation template as s3tables-otlp.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Description: Amazon S3 Tables resources for duckdb-otlp.

Parameters:
  TableBucketName:
    Type: String
    Description: Name of the Amazon S3 Tables table bucket.
    MinLength: 3
    MaxLength: 63
  NamespaceName:
    Type: String
    Description: Single-level namespace for duckdb-otlp tables.
    Default: otlp

Resources:
  OtlpTableBucket:
    Type: AWS::S3Tables::TableBucket
    Properties:
      TableBucketName: !Ref TableBucketName
      Tags:
        - Key: project
          Value: duckdb-otlp

  OtlpNamespace:
    Type: AWS::S3Tables::Namespace
    Properties:
      TableBucketARN: !GetAtt OtlpTableBucket.TableBucketARN
      Namespace: !Ref NamespaceName

Outputs:
  TableBucketName:
    Value: !Ref TableBucketName
  TableBucketArn:
    Value: !GetAtt OtlpTableBucket.TableBucketARN
  NamespaceName:
    Value: !Ref NamespaceName

Deploy it:

aws cloudformation deploy \
  --profile "$AWS_PROFILE" \
  --region "$AWS_REGION" \
  --stack-name "$STACK_NAME" \
  --template-file s3tables-otlp.yaml \
  --parameter-overrides \
    TableBucketName="$TABLE_BUCKET_NAME" \
    NamespaceName=otlp

Read the table bucket ARN. DuckDB attaches this ARN; DuckDB cannot attach an s3:// path for S3 Tables.

export TABLE_BUCKET_ARN="$(
  aws cloudformation describe-stacks \
    --profile "$AWS_PROFILE" \
    --region "$AWS_REGION" \
    --stack-name "$STACK_NAME" \
    --query "Stacks[0].Outputs[?OutputKey=='TableBucketArn'].OutputValue | [0]" \
    --output text
)"

Configure

Create s3tables.env:

DUCKDB_MODE=s3-tables
DUCKDB_OTLP_TOKEN=dev-token-123456

DUCKDB_CATALOG=s3tables
DUCKDB_SCHEMA=otlp

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

AWS_REGION=us-west-2
AWS_PROFILE=cli-dev
S3_TABLES_BUCKET_ARN=<table-bucket-arn>

Replace <table-bucket-arn> with the TABLE_BUCKET_ARN value from CloudFormation.

Start the server

Prefer to run manually in the DuckDB shell? See Run manually.

Mount your AWS config read-only so DuckDB can use the configured profile:

docker run --rm --name duckdb-otlp \
  --env-file s3tables.env \
  -p 4318:4318 \
  -p 9494:9494 \
  -v "$HOME/.aws:/root/.aws:ro" \
  ghcr.io/smithclay/duckdb-otlp:latest

The container creates these Iceberg tables in the S3 Tables namespace if they do not exist:

  • s3tables.otlp.otlp_logs
  • s3tables.otlp.otlp_traces
  • s3tables.otlp.otlp_metrics_gauge
  • s3tables.otlp.otlp_metrics_sum
  • s3tables.otlp.otlp_metrics_histogram
  • s3tables.otlp.otlp_metrics_exp_histogram

POST a log record

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer dev-token-123456' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"s3-tables-demo"}},{"key":"deployment.environment","value":{"stringValue":"docs"}}]},"scopeLogs":[{"scope":{"name":"duckdb-otlp-guide"},"logRecords":[{"timeUnixNano":"1704067200000000000","observedTimeUnixNano":"1704067200123456789","severityNumber":9,"severityText":"INFO","body":{"stringValue":"hello from Amazon S3 Tables"},"attributes":[{"key":"guide","value":{"stringValue":"stream-to-s3-tables"}}]}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

Rows are accepted before they are durable. They commit automatically in the background, on graceful shutdown, or immediately after an explicit flush.

Query committed rows

Flush and query through Quack from a host DuckDB process:

The server image is distroless and has no shell or DuckDB CLI, so do not use docker exec ... sh -c for inspection SQL. The examples in this guide enable Quack, publish port 9494, and use DuckDB 2.0’s CONNECT statement for ordinary server-side SQL. Replace <fingerprint> with the TLS certificate fingerprint the container prints at startup (see Query with Quack).

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>');
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

SELECT service_name, severity_text, body
FROM s3tables.otlp.otlp_logs
WHERE service_name = 's3-tables-demo'
ORDER BY time_unix_nano DESC
LIMIT 5;

DISCONNECT;
SQL

Stop cleanly

If you plan to delete the S3 Tables resources immediately, skip this step and use Clean up instead.

docker stop duckdb-otlp

The image sends otlp_stop('otlp:0.0.0.0:4318') during shutdown, so remaining buffered rows are committed before the process exits.

Clean up

Drop the Iceberg tables before deleting the CloudFormation stack; S3 Tables table buckets cannot be removed while tables remain:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT status FROM otlp_stop('otlp:0.0.0.0:4318');
DROP TABLE IF EXISTS s3tables.otlp.otlp_logs;
DROP TABLE IF EXISTS s3tables.otlp.otlp_traces;
DROP TABLE IF EXISTS s3tables.otlp.otlp_metrics_gauge;
DROP TABLE IF EXISTS s3tables.otlp.otlp_metrics_sum;
DROP TABLE IF EXISTS s3tables.otlp.otlp_metrics_histogram;
DROP TABLE IF EXISTS s3tables.otlp.otlp_metrics_exp_histogram;
DETACH s3tables;

DISCONNECT;
SQL

docker stop duckdb-otlp

Then delete the S3 Tables table bucket and namespace stack:

aws cloudformation delete-stack \
  --profile "$AWS_PROFILE" \
  --region "$AWS_REGION" \
  --stack-name "$STACK_NAME"

aws cloudformation wait stack-delete-complete \
  --profile "$AWS_PROFILE" \
  --region "$AWS_REGION" \
  --stack-name "$STACK_NAME"

Run manually

To run this configuration in a DuckDB 2.0+ shell instead of the daemon, execute the SQL below. Replace bracketed values with the corresponding values from this guide. Keep the shell open while clients send telemetry.

duckdb duckdb-otlp-control.duckdb
-- The daemon embeds otlp statically; the shell loads the extension explicitly.
INSTALL otlp FROM community;
LOAD otlp;

-- Configure the AWS credential chain and attach the S3 Tables catalog.
INSTALL iceberg;
INSTALL aws;
INSTALL httpfs;
LOAD iceberg;
LOAD aws;
LOAD httpfs;
CREATE OR REPLACE SECRET s3_tables_secret (
  TYPE s3,
  PROVIDER credential_chain,
  CHAIN config,
  PROFILE 'cli-dev',
  REGION 'us-west-2'
);
ATTACH '<table-bucket-arn>' AS s3tables (
  TYPE iceberg,
  ENDPOINT_TYPE s3_tables
);

-- Create the target schema before starting ingestion.
CREATE SCHEMA IF NOT EXISTS s3tables.otlp;

-- Match the daemon's default-catalog setting for unqualified queries.
USE s3tables;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := 's3tables',
  schema := 'otlp',
  token := 'dev-token-123456',
  allow_other_hostname := true
);

-- The guide's daemon configuration also enables Quack.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

Before closing DuckDB, stop both listeners cleanly:

-- Stop Quack, then commit buffered telemetry and stop OTLP.
CALL quack_stop('quack:0.0.0.0:9494');
SELECT status, dropped_rows
FROM otlp_stop('otlp:0.0.0.0:4318');

Troubleshooting

  • If the container cannot find AWS credentials at startup, confirm AWS_PROFILE in s3tables.env matches a profile in the mounted $HOME/.aws directory.
  • If attachment fails, confirm S3_TABLES_BUCKET_ARN is the table bucket ARN from CloudFormation. DuckDB cannot attach an s3:// path for S3 Tables.
  • If no rows appear after a 202 response, run the flush command before querying.
  • If stack deletion fails, rerun Clean up while the container is still running, then delete the CloudFormation stack again.
  • S3 Tables stores live ingest timestamp columns with microsecond precision because the Iceberg catalog does not accept DuckDB TIMESTAMP_NS columns.
  • If DuckDB reports unsupported catalog checkpointing, no action is required; ingest, flush, and stop durability behavior stays the same.

See also

How to Stream OTLP to Cloudflare R2 Data Catalog

Use the duckdb-otlp Docker image in r2-data-catalog mode to stream OTLP/HTTP exports into an Iceberg catalog hosted by Cloudflare R2 Data Catalog.

The container initializes DuckDB, loads the required extensions, attaches the R2 Data Catalog warehouse, starts the ingest server, and commits accepted rows in batches.

Choose R2 Data Catalog when you want Cloudflare to host an Iceberg REST catalog for an R2 bucket. To write Iceberg metadata and Parquet files to a regular R2 bucket through the S3-compatible API, use a different catalog setup.

Live ingestion uses OTLP/HTTP on port 4318. WASM builds do not include the ingest server.

Create R2 Data Catalog resources

Choose a bucket name and a Cloudflare account/token that can create R2 buckets and enable R2 Data Catalog:

export CLOUDFLARE_ACCOUNT_ID=<account-id>
export CLOUDFLARE_API_TOKEN=<r2-admin-read-write-token>
export R2_BUCKET="duckdb-otlp-r2catalog-${CLOUDFLARE_ACCOUNT_ID}"

Do not paste the API token into logs or source files. The token needs R2 storage read/write and R2 Data Catalog read/write permissions. Cloudflare’s R2 Admin Read & Write token includes both.

Create the bucket:

wrangler r2 bucket create "$R2_BUCKET"

Enable R2 Data Catalog on the bucket:

wrangler r2 bucket catalog enable "$R2_BUCKET"

Wrangler prints the catalog values DuckDB needs:

Catalog URI: 'https://catalog.cloudflarestorage.com/<account-id>/<bucket-name>'
Warehouse: '<account-id>_<bucket-name>'

You do not need to save either value. duckdb-otlp derives the catalog URI and the warehouse from CLOUDFLARE_ACCOUNT_ID and R2_BUCKET, which are the same two values Wrangler built them from. Set CLOUDFLARE_CATALOG_URI only if your catalog is not at the standard address.

Enable R2 Data Catalog table maintenance before sustained ingest. Live OTLP ingest commits rows in batches, which can leave many small data files and table snapshots without Cloudflare managed maintenance.

wrangler r2 bucket catalog compaction enable "$R2_BUCKET" \
  --target-size 128 \
  --token "$CLOUDFLARE_API_TOKEN"

wrangler r2 bucket catalog snapshot-expiration enable "$R2_BUCKET" \
  --token "$CLOUDFLARE_API_TOKEN" \
  --older-than-days 7 \
  --retain-last 10

Compaction combines small files into larger files for faster queries; catalog-level compaction applies retroactively to existing tables. Snapshot expiration removes old Iceberg snapshots and unreferenced files according to the retention policy. Snapshot expiration requires Wrangler 4.56.0 or newer.

You also need an R2 S3-compatible access key pair that can write objects to the bucket. Save those values as R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY in the next step.

Configure

Create cloudflare.env:

DUCKDB_MODE=r2-data-catalog
DUCKDB_OTLP_TOKEN=dev-token-123456

DUCKDB_CATALOG=r2catalog
DUCKDB_SCHEMA=otlp

DUCKDB_QUACK_PORT=9494
DUCKDB_QUACK_TOKEN=dev-quack-token-123456

CLOUDFLARE_ACCOUNT_ID=<account-id>
R2_BUCKET=<bucket-name>
CLOUDFLARE_API_TOKEN=<r2-admin-read-write-token>

R2_ACCESS_KEY_ID=<r2-s3-access-key-id>
R2_SECRET_ACCESS_KEY=<r2-s3-secret-access-key>

The three settings above the blank line are the required ones. The key pair is optional: leave it out and DuckDB resolves R2 access from its own secret store instead, which is the better choice when you would rather not put credentials in an env file. Create the secret once, against the same data directory the server uses:

duckdb -c "
  INSTALL httpfs; LOAD httpfs;
  CREATE PERSISTENT SECRET cloudflare_r2_secret (
    TYPE s3,
    KEY_ID '<r2-s3-access-key-id>',
    SECRET '<r2-s3-secret-access-key>',
    REGION 'auto',
    ENDPOINT '<account-id>.r2.cloudflarestorage.com',
    URL_STYLE 'path'
  );"

The server prints which of the two it is using on startup (Credentials: ...). To keep secrets somewhere other than $HOME/.duckdb/stored_secrets, set SET secret_directory = '...' before creating it and pass the same directory to the server with --secret-dir.

Start the server

Prefer to run manually in the DuckDB shell? See Run manually.

docker run --rm --name duckdb-otlp \
  --env-file cloudflare.env \
  -p 4318:4318 \
  -p 9494:9494 \
  ghcr.io/smithclay/duckdb-otlp:latest

The container creates these Iceberg tables in the R2 Data Catalog namespace if they do not exist:

  • r2catalog.otlp.otlp_logs
  • r2catalog.otlp.otlp_traces
  • r2catalog.otlp.otlp_metrics_gauge
  • r2catalog.otlp.otlp_metrics_sum
  • r2catalog.otlp.otlp_metrics_histogram
  • r2catalog.otlp.otlp_metrics_exp_histogram

POST a log record

In another terminal:

curl -sS http://localhost:4318/v1/logs \
  -H 'Authorization: Bearer dev-token-123456' \
  -H 'Content-Type: application/json' \
  -d '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"r2-data-catalog-demo"}},{"key":"deployment.environment","value":{"stringValue":"docs"}}]},"scopeLogs":[{"scope":{"name":"duckdb-otlp-guide"},"logRecords":[{"timeUnixNano":"1704067200000000000","observedTimeUnixNano":"1704067200123456789","severityNumber":9,"severityText":"INFO","body":{"stringValue":"hello from Cloudflare R2 Data Catalog"},"attributes":[{"key":"guide","value":{"stringValue":"stream-to-r2-data-catalog"}}]}]}]}]}'

Response:

{"status":"buffered","rows":1,"batches":1}

Rows are accepted before they are durable. They commit automatically in the background, on graceful shutdown, or immediately after an explicit flush.

Query committed rows

Flush and query through Quack from a host DuckDB process:

The server image is distroless and has no shell or DuckDB CLI, so do not use docker exec ... sh -c for inspection SQL. The examples in this guide enable Quack, publish port 9494, and use DuckDB 2.0’s CONNECT statement for ordinary server-side SQL. Replace <fingerprint> with the TLS certificate fingerprint the container prints at startup (see Query with Quack).

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>');
CONNECT otel;

SELECT * FROM otlp_flush('otlp:0.0.0.0:4318');

SELECT service_name, severity_text, body
FROM r2catalog.otlp.otlp_logs
WHERE service_name = 'r2-data-catalog-demo'
ORDER BY time_unix_nano DESC
LIMIT 5;

DISCONNECT;
SQL

Stop cleanly

If you plan to delete the R2 Data Catalog resources immediately, skip this step and use Clean up instead.

docker stop duckdb-otlp

The image sends otlp_stop('otlp:0.0.0.0:4318') during shutdown, so remaining buffered rows are committed before the process exits.

Clean up

Drop the Iceberg tables before disabling the catalog and deleting the R2 bucket:

duckdb <<'SQL'
INSTALL quack;
LOAD quack;

CREATE SECRET duckdb_otlp_quack (
  TYPE quack,
  SCOPE 'quack:localhost:9494',
  TOKEN 'dev-quack-token-123456'
);

ATTACH 'quack:localhost:9494' AS otel (TYPE quack, SSL_FINGERPRINT '<fingerprint>'); -- printed by the container at startup
CONNECT otel;

SELECT status FROM otlp_stop('otlp:0.0.0.0:4318');
DROP TABLE IF EXISTS r2catalog.otlp.otlp_logs;
DROP TABLE IF EXISTS r2catalog.otlp.otlp_traces;
DROP TABLE IF EXISTS r2catalog.otlp.otlp_metrics_gauge;
DROP TABLE IF EXISTS r2catalog.otlp.otlp_metrics_sum;
DROP TABLE IF EXISTS r2catalog.otlp.otlp_metrics_histogram;
DROP TABLE IF EXISTS r2catalog.otlp.otlp_metrics_exp_histogram;
DETACH r2catalog;

DISCONNECT;
SQL

docker stop duckdb-otlp

Then disable the catalog and delete the bucket:

wrangler r2 bucket catalog disable "$R2_BUCKET"
wrangler r2 bucket delete "$R2_BUCKET"

If bucket deletion reports that the bucket is not empty, delete the remaining catalog objects and retry. For a bucket you created for this guide, those objects are the Iceberg metadata and data files under __r2_data_catalog/:

export R2_OBJECTS_API="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/r2/buckets/${R2_BUCKET}/objects"

curl -fsS \
  -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
  "$R2_OBJECTS_API" |
  jq -r '.result[]?.key' |
  while IFS= read -r key; do
    encoded="$(node -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$key")"
    curl -fsS -X DELETE \
      -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
      "${R2_OBJECTS_API}/${encoded}" >/dev/null
  done

wrangler r2 bucket delete "$R2_BUCKET"

Run manually

To run this configuration in a DuckDB 2.0+ shell instead of the daemon, execute the SQL below. Replace bracketed values with the corresponding values from this guide. Keep the shell open while clients send telemetry.

duckdb duckdb-otlp-control.duckdb
-- The daemon embeds otlp statically; the shell loads the extension explicitly.
INSTALL otlp FROM community;
LOAD otlp;

-- Configure R2 object storage and attach the Iceberg REST catalog.
INSTALL iceberg;
INSTALL httpfs;
LOAD iceberg;
LOAD httpfs;
CREATE OR REPLACE SECRET cloudflare_r2_secret (
  TYPE s3,
  KEY_ID '<r2-s3-access-key-id>',
  SECRET '<r2-s3-secret-access-key>',
  REGION 'auto',
  ENDPOINT '<account-id>.r2.cloudflarestorage.com',
  URL_STYLE 'path'
);
CREATE OR REPLACE SECRET cloudflare_catalog_secret (
  TYPE iceberg,
  TOKEN '<r2-admin-read-write-token>'
);
ATTACH '<account-id>_<bucket-name>' AS r2catalog (
  TYPE iceberg,
  ENDPOINT 'https://catalog.cloudflarestorage.com/<account-id>/<bucket-name>',
  SECRET cloudflare_catalog_secret
);

-- Create the target schema before starting ingestion.
CREATE SCHEMA IF NOT EXISTS r2catalog.otlp;

-- Match the daemon's default-catalog setting for unqualified queries.
USE r2catalog;

-- Start OTLP/HTTP. Seal cadence, file sizes, and buffer limits use defaults;
-- override only as needed — see the Live Ingest Reference:
-- https://smithclay.github.io/duckdb-otlp/reference/serve/
SELECT listen_url, catalog_name, schema_name
FROM otlp_serve(
  'otlp:0.0.0.0:4318',
  catalog := 'r2catalog',
  schema := 'otlp',
  token := 'dev-token-123456',
  allow_other_hostname := true
);

-- The guide's daemon configuration also enables Quack.
INSTALL quack;
LOAD quack;
SELECT listen_uri
FROM quack_serve(
  'quack:0.0.0.0:9494',
  token := 'dev-quack-token-123456',
  allow_other_hostname := true
);

Before closing DuckDB, stop both listeners cleanly:

-- Stop Quack, then commit buffered telemetry and stop OTLP.
CALL quack_stop('quack:0.0.0.0:9494');
SELECT status, dropped_rows
FROM otlp_stop('otlp:0.0.0.0:4318');

Troubleshooting

  • If the container cannot attach the catalog at startup, confirm CLOUDFLARE_CATALOG_URI, CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID, and R2_BUCKET all refer to the same bucket.
  • If the container attaches the catalog but cannot write files, confirm R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY can write objects to the R2 bucket.
  • If no rows appear after a 202 response, run the flush command before querying.
  • If bucket deletion reports that the bucket is not empty, delete the remaining catalog objects as shown in Clean up, then retry wrangler r2 bucket delete.
  • R2 Data Catalog supports R2 buckets in the default jurisdiction.
  • R2 Data Catalog stores live ingest timestamp columns with microsecond precision because the Iceberg catalog does not accept DuckDB TIMESTAMP_NS columns.
  • If DuckDB reports unsupported catalog checkpointing, no action is required; ingest, flush, and stop durability behavior stays the same.

See also

API Reference

The DuckDB OpenTelemetry Extension API includes file readers and live-ingest functions. The OTLP file readers accept a path or glob pattern and detect OTLP JSON, JSONL, and protobuf; the separate OTAP readers decode the columnar Arrow encoding (BatchArrowRecords). Native builds also support live ingest.

Table Functions

Use these table functions to read OTLP data:

Traces

read_otlp_traces(path)

Streams trace spans with identifiers, attributes, events, and links. See the schema reference for all 24 columns.

Parameters:

  • path (VARCHAR): File path or glob pattern. DuckDB file systems provide local, S3, HTTP(S), Azure, and GCS access.

Logs

read_otlp_logs(path)

Reads log records with severity, body, and trace correlation. See the schema reference for all 18 columns.

Parameters: Same as read_otlp_traces

Metrics

read_otlp_metrics_gauge(path)

Returns gauge metrics (17 columns). See the schema reference for details.

read_otlp_metrics_sum(path)

Returns sum/counter metrics (19 columns) with int_value, double_value, aggregation_temporality, and is_monotonic. See the schema reference for details.

read_otlp_metrics_histogram(path)

Returns standard histogram metrics (22 columns) with counts, sum, min/max, explicit bucket bounds, and bucket counts. See the schema reference for details.

read_otlp_metrics_exp_histogram(path)

Returns exponential histogram metrics (27 columns) with scale, zero bucket, positive buckets, negative buckets, and aggregation temporality. See the schema reference for details.

Parameters: Same as read_otlp_traces

read_otlp_metrics(path) and read_otlp_metrics_summary(path) are registered placeholders. Use the shape-specific metric readers above.

OpenTelemetry Arrow Protocol (OTAP)

OTAP is the columnar Arrow encoding of OpenTelemetry data (canonical BatchArrowRecords), distinct from OTLP’s protobuf/JSON wire format. The read_otap_* readers decode OTAP files into the same flattened schemas as their read_otlp_* counterparts — only the input encoding differs:

  • read_otap_traces(path)
  • read_otap_logs(path)
  • read_otap_metrics_gauge(path)
  • read_otap_metrics_sum(path)
  • read_otap_metrics_histogram(path)
  • read_otap_metrics_exp_histogram(path)

Parameters: Same as read_otlp_traces (a path or glob).

Because OTAP and OTLP mean different things, they are separate functions rather than a format flag — pick the reader that matches your input encoding. Each file must be a self-contained BatchArrowRecords message; one file is decoded with one decoder. Streams that span multiple files relying on cross-message Arrow dictionary reuse are not supported by the file readers.

One signal per file, multiple metric shapes per file. A canonical OTAP message carries one signal family — logs or traces or metrics — so call the reader that matches the file. A single metrics file can hold several metric shapes at once: read_otap_metrics_gauge, read_otap_metrics_sum, read_otap_metrics_histogram, and read_otap_metrics_exp_histogram each extract their shape from the same file, just like the read_otlp_metrics_* readers (summary points are skipped). Pointing a reader at a file of a different signal, or at an envelope that mixes incompatible payloads, is a hard error — it never returns partial or mis-typed rows.

Compression: OpenTelemetry producers default to Zstandard. Native builds decode uncompressed, LZ4, and Zstandard OTAP. The WebAssembly build decodes uncompressed and LZ4 only (no Zstandard); a Zstandard OTAP file there fails with an Arrow IPC error.

Live Ingest

In native builds, you can run a server that accepts live telemetry over HTTP or gRPC and streams it into the default DuckDB catalog or an attached writable catalog such as DuckLake or an Iceberg REST catalog. The server buffers rows and commits them in batches: an accepted request returns immediately (HTTP 202 Accepted / gRPC OK), and rows become durable at the next background commit or on graceful stop. Current native builds commit after about 5 seconds for the oldest buffered row, or when admitted request-body bytes reach about 128 MiB.

Each serve function is bound to its own URI scheme (no mixing). otlp_serve runs the OTLP protocol on the otlp: scheme: OTLP/HTTP by default (port 4318), or standard OTLP/gRPC unary Export with transport := 'grpc'. otap_serve runs the canonical OTAP/Arrow bidirectional streaming services (Arrow{Logs,Traces,Metrics}Service, all six signals) over gRPC on the otap: scheme (port 4317). The two gRPC service sets are disjoint — otlp_serve(transport := 'grpc') serves only OTLP unary, otap_serve only OTAP/Arrow. The lifecycle functions below are transport-agnostic.

  • otlp_serve([uri], transport := 'http'|'grpc', catalog := '<attached_db>', ...) - Start an OTLP ingest server on the otlp: scheme, target a catalog, and create/validate the target tables. transport defaults to 'http' (OTLP/HTTP); 'grpc' serves OTLP/gRPC unary Export. Pass a URI list with a parallel transport list (for example otlp_serve(['otlp:localhost:4318', 'otlp:localhost:4317'], transport := ['http', 'grpc'])) to feed one server from several listeners.
  • otap_serve([uri], catalog := '<attached_db>', ...) - Start an OTAP/Arrow gRPC streaming server (otap: scheme; defaults to otap:localhost:4317, gRPC-only). Same parameters as otlp_serve. OTAP/Arrow streams keep one stateful decoder per stream (cross-message Arrow dictionary reuse).
  • otlp_flush(uri) - Force a synchronous commit when readers need the latest accepted rows now.
  • otlp_stop(uri) - Stop the server that owns listener uri, including its other listeners (commits remaining rows first).
  • otlp_stop() - Stop every server on this database, committing each before returning. One row per server. Use this before closing a database when you did not start every server yourself.
  • otlp_server_list() - List running listeners with their server’s live counters, buffer state, and health.
  • otlp_seal_list() - List recent seal attempts with append/commit timing, row/byte counts, and any error.

See the Serve Reference for parameters, catalog targeting, endpoints, auth, and buffered commit behavior. For task-oriented walkthroughs, start with the Live Ingest Quickstart, Stream to Local DuckLake, Stream to Remote DuckLake, Stream to Parquet, Stream to Amazon S3 Tables, or Stream to Cloudflare R2 Data Catalog.

Discovering these functions from SQL

Every function this extension registers carries its own documentation in DuckDB’s catalog, so a connected client — including an agent that has nothing but a SQL connection — can read it without leaving the database:

LOAD otlp;
SELECT function_name, description, parameters, examples, categories
FROM duckdb_functions()
WHERE list_contains(categories, 'opentelemetry');

The categories column separates the two wire protocols (otlp vs otap) from the live-ingest functions (ingest, monitoring). read_otlp_metrics and read_otlp_metrics_summary are described but carry no example, because every call to them raises a not-implemented error.

Examples

For task-oriented examples, see the How-to Guides.

For complete schema details, see the Schema Reference.

CLI Reference

duckdb-otlp is a single binary that receives OpenTelemetry data and writes it to a DuckDB-attached catalog or Parquet. It runs on macOS and Linux, and is the same binary that ships in the Docker image.

With no arguments it starts a working local receiver — no configuration file, no environment variables, no credentials:

duckdb-otlp

That listens for OTLP/HTTP on 127.0.0.1:4318 and OTLP/gRPC on 127.0.0.1:4317, and streams into a local DuckLake lakehouse under $XDG_DATA_HOME/duckdb-otlp.

Install

Install script

curl -fsSL https://smithclay.github.io/duckdb-otlp/install.sh | sh

That resolves the latest release, downloads the tarball for your platform, verifies it against the release’s SHA256SUMS, and installs duckdb-otlp into $HOME/.local/bin. It needs curl or wget and sha256sum or shasum; nothing is installed if the checksum does not match. Pipe options through sh -s --:

# A specific release, installed system-wide
curl -fsSL https://smithclay.github.io/duckdb-otlp/install.sh | sudo sh -s -- \
  --version v0.7.2 --bin-dir /usr/local/bin
OptionEnvironment variableDefault
--version <tag>DUCKDB_OTLP_VERSIONthe latest release
--bin-dir <dir>DUCKDB_OTLP_BIN_DIR$HOME/.local/bin
--platform <id>DUCKDB_OTLP_PLATFORMdetected from uname

A flag always wins over its variable. Re-running the script upgrades in place: the new binary is staged next to the old one and renamed over it, so a running duckdb-otlp is never left half-written. Exit codes match the CLI’s own — 0 installed, 1 the install failed, 2 the command line was wrong — and everything it prints goes to stderr.

Homebrew

brew install smithclay/tap/duckdb-otlp

brew services start duckdb-otlp runs duckdb-otlp serve with its defaults: OTLP/HTTP on 127.0.0.1:4318, OTLP/gRPC on 127.0.0.1:4317, and a local DuckLake under $XDG_DATA_HOME/duckdb-otlp (~/.local/share/duckdb-otlp when unset). The service can only run those defaults, because duckdb-otlp has no configuration file; to change the mode, ports, bind host, or token, run duckdb-otlp serve yourself instead.

Release tarballs

Each release ships a tarball per platform — linux-amd64, linux-arm64, darwin-amd64, darwin-arm64 — holding a single executable named duckdb-otlp, plus a SHA256SUMS file. To do by hand what the script does:

VERSION=v0.7.2
PLATFORM=darwin-arm64    # or linux-amd64, linux-arm64, darwin-amd64
BASE=https://github.com/smithclay/duckdb-otlp/releases/download/$VERSION

curl -fsSLO "$BASE/duckdb-otlp-$VERSION-$PLATFORM.tar.gz"
curl -fsSLO "$BASE/SHA256SUMS"
shasum -a 256 -c SHA256SUMS --ignore-missing
tar -xzf "duckdb-otlp-$VERSION-$PLATFORM.tar.gz"
sudo mv duckdb-otlp /usr/local/bin/

On Linux use sha256sum -c SHA256SUMS --ignore-missing instead of shasum. macOS binaries are unsigned and unnotarized, so Gatekeeper will quarantine one downloaded through a browser; curl does not set the quarantine attribute, and xattr -d com.apple.quarantine duckdb-otlp clears it if you hit it.

The container ships the same binary:

docker run --rm -p 4318:4318 ghcr.io/smithclay/duckdb-otlp:latest

Commands

CommandWhat it does
duckdb-otlp [serve]Start the OTLP listeners. The default when no subcommand is given.
duckdb-otlp validateResolve the configuration, print the effective settings and generated SQL, exit.
duckdb-otlp doctorCheck every configured listener and report each one. Exit 0 means healthy.
duckdb-otlp versionPrint the version.
duckdb-otlp help [COMMAND]Show help for the tool or one command.

Reading files and querying data

duckdb-otlp only receives. To read OTLP/OTAP files, or to query what it stored, use the otlp extension from the duckdb CLI:

duckdb -c "INSTALL otlp FROM community; LOAD otlp;
           COPY (FROM read_otlp_traces('traces.pb')) TO 'traces.parquet'"

While the server runs it holds the catalog’s write lock, so query it over Quack (--quack PORT) instead.

Mistyping a command is an error rather than a silent fall-through to serve:

$ duckdb-otlp valdate
ERROR: Unknown command "valdate".
Did you mean `duckdb-otlp validate`?

Exit codes and output streams

CodeMeaning
0Success.
1The work failed — a listener is down, the configuration is incomplete, startup failed.
2The command line was wrong — unknown command or flag, a missing or extra argument.

The split matters to anything that checks the result rather than reading it: 2 says fix the invocation, 1 says the invocation was fine and the work was not.

The banner and reports go to stdout; warnings and errors go to stderr. The serve banner is written unbuffered, so a redirected or captured stdout (docker logs, a systemd journal, a CI log) shows it as the server starts rather than when it stops.

Configuration precedence

Command-line flag, then environment variable, then built-in default. Every flag that maps onto a setting overrides the matching variable, so --http 4318 wins over DUCKDB_OTLP_HTTP_PORT=9999. A flag is layered over the environment rather than written into it, so its value — a --token above all — stays inside the configuration and is never published to the rest of the process.

Each command accepts only the flags that apply to it. doctor takes every serve flag except --init-sql and --dry-run, and --json belongs to doctor alone. Naming a flag outside its command is an error that says where the flag does belong:

$ duckdb-otlp doctor --init-sql init.sql
ERROR: `doctor` does not accept "--init-sql"; it is a flag of: serve, validate.

duckdb-otlp help COMMAND lists what a command takes.

serve

duckdb-otlp serve [flags]
FlagVariableDefault
-m, --mode MODEDUCKDB_MODElocal-ducklake
--host HOSTDUCKDB_OTLP_HOST127.0.0.1
--http PORTDUCKDB_OTLP_HTTP_PORT4318 (0 disables)
--grpc PORTDUCKDB_OTLP_GRPC_PORT4317 (0 disables)
--otap PORTDUCKDB_OTLP_OTAP_PORToff
--data-dir DIRDUCKDB_OTLP_DATA_DIR$XDG_DATA_HOME/duckdb-otlp
--database PATHDUCKDB_DATABASE<data-dir>/duckdb-otlp-control.duckdb
--catalog NAMEDUCKDB_CATALOGmode-dependent
--schema NAMEDUCKDB_SCHEMAmode-dependent
--init-sql PATHDUCKDB_OTLP_INIT_SQL(none)
--secret-dir DIRDUCKDB_OTLP_SECRET_DIR$HOME/.duckdb/stored_secrets
--token TOKENDUCKDB_OTLP_TOKEN(none)
--no-authDUCKDB_OTLP_DISABLE_AUTH0
--quack PORTDUCKDB_QUACK_PORToff (0 disables)
--quack-token TOKENDUCKDB_QUACK_TOKEN(none)
—DUCKDB_QUACK_SSL_CERT_FILE, DUCKDB_QUACK_SSL_KEY_FILEself-signed (generated under <data dir>/.duckdb/extension_data/quack, so it survives a redeploy with the data)
--startup-timeout SECSDUCKDB_OTLP_STARTUP_TIMEOUT60

Passing a token as a flag makes it visible in the process list; prefer DUCKDB_OTLP_TOKEN outside of local use.

The otlp_serve tuning options are daemon settings too, named DUCKDB_OTLP_ plus the option in upper case: DUCKDB_OTLP_HTTP_THREADS, DUCKDB_OTLP_MAX_BODY_BYTES, DUCKDB_OTLP_MAX_BUFFERED_BYTES, DUCKDB_OTLP_SEAL_TARGET_BYTES, DUCKDB_OTLP_SEAL_MAX_AGE_MS, DUCKDB_OTLP_TARGET_FILE_SIZE, DUCKDB_OTLP_MAINTENANCE_RETENTION_MS, DUCKDB_OTLP_MAINTENANCE_INTERVAL_MS, DUCKDB_OTLP_PROMOTE_RESOURCE_ATTRIBUTES and DUCKDB_OTLP_PROMOTE_SCOPE_ATTRIBUTES. An unset one keeps the extension’s default.

Destinations (--mode)

A mode is a preset: a SQL file (src/server/modes/) compiled into the binary, which installs extensions, creates secrets and attaches the catalog. duckdb-otlp validate --mode MODE prints it expanded. Each one is a point in a grid of three independent choices — the catalog kind, where that catalog lives, and where the data files go.

ModeCatalogCatalog storeData filesRequired settings
local-ducklake (default)DuckLakelocal DuckDB filelocal directory(none)
parquet(none)—local directory or s3://AWS_REGION for S3
aws-ducklakeDuckLakelocal DuckDB files3://DUCKLAKE_DATA_PATH, AWS_REGION
gcp-ducklakeDuckLakePostgresgcss://DUCKLAKE_DATA_PATH, PGHOST, PGDATABASE, PGUSER, PGPASSWORD
r2-local-ducklakeDuckLakelocal DuckDB fileR2R2_BUCKET, CLOUDFLARE_ACCOUNT_ID
r2-neon-ducklakeDuckLakePostgresR2the two above, plus PGHOST, PGDATABASE, PGUSER, PGPASSWORD
r2-data-catalogIceberg RESTCloudflareR2 (catalog-managed)R2_BUCKET, CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN
s3-tablesIceberg RESTAWSS3 (catalog-managed)S3_TABLES_BUCKET_ARN, AWS_REGION
none(whatever --init-sql attaches)——(none)

Missing settings are reported together, in one run:

$ duckdb-otlp validate --mode r2-data-catalog
ERROR: Missing 3 required settings for DUCKDB_MODE=r2-data-catalog:
  CLOUDFLARE_API_TOKEN
  CLOUDFLARE_ACCOUNT_ID  (or set CLOUDFLARE_WAREHOUSE)
  R2_BUCKET  (or set CLOUDFLARE_WAREHOUSE)

Storage settings

One name per concept, across every mode that uses it.

SettingUsed byNotes
DUCKLAKE_DATA_PATHevery DuckLake modewhere Parquet data files go
DUCKLAKE_CATALOG_PATHDuckLake modes with a local cataloga postgres:… value moves the catalog to Postgres
PARQUET_EXPORT_PATHparquetlocal path or s3:// (default <data-dir>/parquet); an s3:// path loads the S3 filesystem and AWS credential chain
S3_BUCKET, S3_PREFIXparquetcomposed into s3://bucket/prefix when PARQUET_EXPORT_PATH is unset
S3_ENDPOINT, S3_URL_STYLEparquetfor S3-compatible storage
S3_TABLES_BUCKET_ARNs3-tablesthe table bucket’s ARN
AWS_REGION, AWS_PROFILEevery AWS modestandard AWS variables; AWS_DEFAULT_REGION also accepted
R2_BUCKET, R2_PREFIXevery R2 modecomposed into s3://bucket/prefix
R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEYevery R2 modeoptional — see below
R2_ENDPOINTevery R2 modedefaults to <account>.r2.cloudflarestorage.com
CLOUDFLARE_ACCOUNT_IDevery R2 modederives the endpoint, catalog URI, and warehouse
CLOUDFLARE_API_TOKENr2-data-catalogR2 Data Catalog read/write token
CLOUDFLARE_CATALOG_URI, CLOUDFLARE_WAREHOUSEr2-data-catalogboth derived from the account and bucket; set only to override
PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD, PGSSLMODEPostgres-catalog modesthe standard libpq names
DUCKDB_OTLP_GCS_EXTENSION_PATHgcp-ducklakea local gcs.duckdb_extension to LOAD instead of the community build; turns on allow_unsigned_extensions. The image sets it to its bundled build
DUCKLAKE_DATA_INLINING_ROW_LIMITevery DuckLake modeDuckLake’s per-insert inlining limit; 0 writes every seal straight to Parquet

Values are not validated beyond being present: a malformed one fails when the SQL runs. Credential values are never interpolated into the generated SQL. They are bound as session variables and referenced with getvariable(), so validate can print the full boot SQL without disclosing them.

Credentials from the DuckDB secret store

Storage credentials do not have to be environment variables. If no key pair is set, the mode emits no CREATE SECRET at all and DuckDB resolves access through its own persistent secret store (or, for AWS and GCP, the provider credential chain). Create the secret once:

duckdb -c "
  INSTALL httpfs; LOAD httpfs;
  CREATE PERSISTENT SECRET r2_storage (
    TYPE s3, KEY_ID '...', SECRET '...',
    REGION 'auto', ENDPOINT '<account>.r2.cloudflarestorage.com', URL_STYLE 'path');"

It is written to $HOME/.duckdb/stored_secrets with 0600 permissions and loaded automatically by every later run. --secret-dir moves that directory, for deployments that mount secrets read-only somewhere else.

The startup banner always names the source it resolved, so the two cases are never confused:

Credentials: R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY
Credentials: DuckDB secret store (no R2 key pair in the environment)

Setting only one half of a key pair is an error, not a silent fall-through to the store.

Reading back the parquet dataset

parquet mode has no catalog: each seal writes straight to <root>/<table>/year=/month=/day=/. Read it with read_parquet, passing hive_partitioning = false (the partition keys live only in the path):

FROM read_parquet('<root>/otlp_logs/**/*.parquet', hive_partitioning = false, union_by_name = true);

With Quack enabled, the server also defines an otlp_<signal> view over each signal once files exist.

--mode none

none attaches nothing and installs nothing. The destination is entirely whatever --init-sql sets up, and --catalog names it:

duckdb-otlp serve --mode none --init-sql ./lake.sql --catalog lake
-- lake.sql: S3 data files with a Postgres catalog, which no preset covers
INSTALL ducklake; INSTALL postgres; INSTALL httpfs;
LOAD ducklake; LOAD postgres; LOAD httpfs;
ATTACH 'ducklake:postgres:dbname=lake host=db.internal' AS lake
  (DATA_PATH 's3://telemetry/lake');

With no --catalog, data lands in the control database — a working single-file server with no lakehouse at all.

Custom DuckDB setup (--init-sql)

--init-sql PATH (or DUCKDB_OTLP_INIT_SQL) runs a SQL script after the mode has attached its catalog and before ingest starts. It is the escape hatch for DuckDB configuration the modes do not model: extra ATTACHes, SET statements, additional secrets, or views over the ingest tables.

-- /etc/duckdb-otlp/init.sql
SET memory_limit = '8GB';
CREATE OR REPLACE VIEW recent_errors AS
  SELECT * FROM otlp_logs WHERE severity_number >= 17;
duckdb-otlp serve --init-sql /etc/duckdb-otlp/init.sql

Behavior worth knowing:

  • serve and validate take it. doctor deliberately does not — the container HEALTHCHECK runs it on every probe, and a liveness check must not execute operator SQL.
  • validate prints the script in place without running it, so duckdb-otlp validate --init-sql ... shows exactly what startup would execute.
  • Failures are fatal. An unreadable path or a failing statement stops startup rather than silently serving without the configuration you asked for. An empty script is a no-op.
  • The script runs before the mode’s catalog becomes the instance default, so it can ATTACH a catalog that --catalog then names.

Adding a second destination

A server has exactly one ingest target — otlp_serve rejects parquet_export_path combined with a catalog, and the commit path writes either Parquet or a catalog, never both. To land data in two places, start a second server on its own port from the init script:

-- alongside the mode's DuckLake catalog on 4318, a plain Parquet drop on 4319
SELECT 1 FROM otlp_serve('otlp:0.0.0.0:4319',
                         parquet_export_path := '/data/parquet',
                         token := getvariable('duckdb_otlp_effective_token'));

This is fan-out by port, not a tee: a batch lands in whichever port received it, so the exporter chooses the destination. There is no supported way to mirror one stream into two targets — one target has one writer by design, which is what keeps a single sealer per catalog.

Servers started this way are stopped and committed on shutdown along with the daemon’s own, because shutdown runs otlp_stop() with no argument.

Selecting listeners

Transports are selected by which ports you set. A non-zero port narrows the set to what you named; 0 switches one transport off without un-defaulting the others:

duckdb-otlp --grpc 4317               # gRPC only
duckdb-otlp --grpc 0                  # HTTP only (gRPC off, HTTP still on its default)
duckdb-otlp --host 0.0.0.0 --token "$TOKEN"

An IPv6 literal works either bracketed or bare, and appears bracketed in the listener URI:

duckdb-otlp --host ::1                      # OTLP http: otlp:[::1]:4318
duckdb-otlp --host :: --token "$TOKEN"      # every interface, IPv6

Every listener, Quack included, binds the one --host. The earlier per-transport settings (OTEL_HTTP_ADDR, OTEL_GRPC_ADDR, DUCKDB_OTLP_TRANSPORTS, DUCKDB_OTLP_LISTEN_URI, DUCKDB_QUACK_ENABLED, DUCKDB_QUACK_ADDR) are rejected at startup with the flag that replaces them.

OTAP/Arrow is a different protocol served by otap_serve, so it cannot be combined with standard OTLP listeners in one process:

duckdb-otlp --otap 4317 --http 0 --grpc 0

Authentication

There is no built-in default token. The rules are:

  • No token, every listener on loopback → authentication is disabled automatically and a notice is printed. Only your machine can reach the listeners.
  • No token, any non-loopback bind (including 0.0.0.0) → startup fails, telling you to set a token or pass --no-auth.
  • A token → it must be at least 16 characters, and it is passed to otlp_serve through a session variable, so it never appears in generated SQL or logs.
  • --no-auth → unauthenticated traffic is accepted anywhere, with a warning.

OpenTelemetry environment variables

OpenTelemetry specifies environment variables for exporters, not receivers. There is no receiver-side standard, so duckdb-otlp honors only the variables whose meaning transfers cleanly, and refuses the ones it cannot actually implement.

VariableTreatment
OTEL_EXPORTER_OTLP_HEADERSAn Authorization=Bearer <token> entry supplies the expected token. Other entries are ignored.
OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_COMPRESSIONAccepted and ignored (client-side only; compressed bodies are always accepted).
OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOLNot read at all.
OTEL_EXPORTER_OTLP_{TRACES,LOGS,METRICS}_ENDPOINTRejected at startup.
OTEL_EXPORTER_OTLP_{CERTIFICATE,CLIENT_KEY,CLIENT_CERTIFICATE}Rejected at startup.

OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_PROTOCOL are ignored deliberately. They are usually already set in a developer’s shell for their application’s exporter; reading them as bind settings would silently move or narrow the listeners. Use --host and --http/--grpc.

The TLS and per-signal-endpoint variables are rejected rather than ignored for the same reason in reverse: this server does not terminate TLS and serves every signal on one listener, so accepting those settings silently would leave you believing something untrue about your deployment. Put a TLS-terminating proxy in front instead.

doctor

duckdb-otlp doctor [serve flags]

Checks that the configured listeners are up, one line per check, exiting 0 only when every one passed. It takes the same flags as serve, so it probes exactly what those settings would bind.

$ duckdb-otlp doctor
ok    OTLP http  127.0.0.1:4318
FAIL  OTLP grpc  127.0.0.1:4317  (no response)

Every check runs even after one fails, so a partial answer is visible rather than just the first problem. --json prints one object instead, for a monitor, a script or an agent that should not be parsing prose:

$ duckdb-otlp doctor --json
{"healthy":false,"checks":[{"check":"OTLP http","endpoint":"127.0.0.1:4318","ok":true},
                           {"check":"OTLP grpc","endpoint":"127.0.0.1:4317","ok":false}]}
``` The container image's `HEALTHCHECK` is this command, and Docker keeps its output in the container's health log. `duckdb-otlp healthcheck` is still accepted as the same command, so existing probes keep working.

## Docker

The image runs the same binary, with container-shaped defaults set in the image rather than in the code:

DUCKDB_OTLP_DATA_DIR=/data DUCKDB_OTLP_HOST=0.0.0.0 DUCKDB_OTLP_HTTP_PORT=4318


Setting the HTTP port selects HTTP alone; add `DUCKDB_OTLP_GRPC_PORT=4317` for gRPC and `DUCKDB_QUACK_PORT=9494` (with `DUCKDB_QUACK_TOKEN`) for Quack.

Because the image binds `0.0.0.0`, it requires a token:

```sh
docker run --rm -p 4318:4318 \
  -e DUCKDB_MODE=local-ducklake \
  -e DUCKDB_OTLP_TOKEN=replace-with-a-private-token \
  -v otlp-data:/data ghcr.io/smithclay/duckdb-otlp:latest

duckdb-otlp-server remains available inside the image as an alias for duckdb-otlp.

Schema Reference

The extension emits typed tables based on the OpenTelemetry ClickHouse exporter schema and aligns fields with the OpenTelemetry Arrow data model where the models overlap. All column names use snake_case.

Table functionColumnsNotes
read_otlp_traces24Spans with identifiers, scope metadata, attributes, events, and links
read_otlp_logs18Log records with severity, body, resource attributes, and trace correlation
read_otlp_metrics_gauge17Gauge metrics with numeric value columns and metadata
read_otlp_metrics_sum19Sum/counter metrics with aggregation temporality
read_otlp_metrics_exp_histogram27Exponential histogram metrics with bucket data
read_otlp_metrics_histogram22Standard histogram metrics with explicit bucket bounds

read_otlp_metrics (union schema) and read_otlp_metrics_summary are registered placeholders.

Traces (read_otlp_traces)

24 columns total:

ColumnTypeDescription
start_time_unix_nanoTIMESTAMP_NSSpan start time
duration_time_unix_nanoBIGINTSpan duration in nanoseconds
trace_idVARCHARTrace identifier (hex string)
span_idVARCHARSpan identifier (hex string)
parent_span_idVARCHARParent span identifier (hex string)
trace_stateVARCHARW3C trace state
service_nameVARCHARService name from resource attributes
service_namespaceVARCHARService namespace from resource attributes
service_instance_idVARCHARService instance ID from resource attributes
nameVARCHAROperation name
kindINTEGERSpan kind (0=unspecified, 1=internal, 2=server, 3=client, 4=producer, 5=consumer)
status_codeINTEGERStatus code (0=unset, 1=ok, 2=error)
status_status_messageVARCHARStatus description
resource_attributesVARCHARResource attributes as JSON string
scope_nameVARCHARInstrumentation scope name
scope_versionVARCHARInstrumentation scope version
scope_attributesVARCHARScope attributes as JSON string
span_attributesVARCHARSpan attributes as JSON string
events_jsonVARCHARSpan events as JSON array
links_jsonVARCHARSpan links as JSON array
dropped_attributes_countINTEGERNumber of dropped attributes
dropped_events_countINTEGERNumber of dropped events
dropped_links_countINTEGERNumber of dropped links
flagsINTEGERTrace flags

The duration_time_unix_nano (span duration) and status_status_message (span status message) column names are taken verbatim from the OpenTelemetry Arrow span schema — they are intentional, not typos, and are kept as-is for data-model alignment even though duration_time_unix_nano holds a duration rather than an absolute timestamp.

Each span is emitted once, even if multiple files are scanned. Use standard DuckDB SQL to join traces back to logs or metrics via trace_id/span_id.

Logs (read_otlp_logs)

18 columns total:

ColumnTypeDescription
time_unix_nanoTIMESTAMP_NSLog timestamp
observed_time_unix_nanoTIMESTAMP_NSTime when the log was observed
trace_idVARCHARTrace identifier for correlation (hex string)
span_idVARCHARSpan identifier for correlation (hex string)
service_nameVARCHARService name from resource attributes
service_namespaceVARCHARService namespace from resource attributes
service_instance_idVARCHARService instance ID from resource attributes
severity_numberINTEGERNumeric severity level (1-24)
severity_textVARCHARSeverity text (e.g., “INFO”, “ERROR”)
event_nameVARCHAREvent name attribute, when present
bodyVARCHARLog message body
resource_attributesVARCHARResource attributes as JSON string
scope_nameVARCHARInstrumentation scope name
scope_versionVARCHARInstrumentation scope version
scope_attributesVARCHARScope attributes as JSON string
log_attributesVARCHARLog record attributes as JSON string
dropped_attributes_countINTEGERNumber of dropped attributes
flagsINTEGERTrace flags

Metrics

Gauge Metrics (read_otlp_metrics_gauge)

17 columns total:

ColumnTypeDescription
time_unix_nanoTIMESTAMP_NSData point timestamp
start_time_unix_nanoTIMESTAMP_NSStart time
nameVARCHARMetric name
descriptionVARCHARMetric description
unitVARCHARMetric unit
int_valueBIGINTInteger value, when encoded as an integer
double_valueDOUBLEFloating point value, when encoded as a double
service_nameVARCHARService name from resource attributes
service_namespaceVARCHARService namespace from resource attributes
service_instance_idVARCHARService instance ID from resource attributes
resource_attributesVARCHARResource attributes as JSON string
scope_nameVARCHARInstrumentation scope name
scope_versionVARCHARInstrumentation scope version
scope_attributesVARCHARScope attributes as JSON string
metric_attributesVARCHARData point attributes as JSON string
flagsINTEGERData point flags
exemplars_jsonVARCHARExemplars as JSON array

Sum Metrics (read_otlp_metrics_sum)

19 columns total (gauge columns plus):

ColumnTypeDescription
aggregation_temporalityINTEGERAggregation temporality (1=delta, 2=cumulative; 0=unspecified, also used for any out-of-spec value)
is_monotonicBOOLEANWhether the sum is monotonic (counter vs. up-down counter)

All gauge columns are included, plus the two sum-specific columns above.

Histogram Metrics (read_otlp_metrics_histogram)

22 columns total:

ColumnTypeDescription
time_unix_nanoTIMESTAMP_NSData point timestamp
start_time_unix_nanoTIMESTAMP_NSStart time
nameVARCHARMetric name
descriptionVARCHARMetric description
unitVARCHARMetric unit
countBIGINTTotal count of observations
sumDOUBLESum of all observations (optional)
minDOUBLEMinimum observed value (optional)
maxDOUBLEMaximum observed value (optional)
bucket_countsBIGINT[]Bucket counts (array of integers)
explicit_boundsDOUBLE[]Explicit bucket boundaries (array of floats)
service_nameVARCHARService name from resource attributes
service_namespaceVARCHARService namespace from resource attributes
service_instance_idVARCHARService instance ID from resource attributes
resource_attributesVARCHARResource attributes as JSON string
scope_nameVARCHARInstrumentation scope name
scope_versionVARCHARInstrumentation scope version
scope_attributesVARCHARScope attributes as JSON string
metric_attributesVARCHARData point attributes as JSON string
flagsINTEGERData point flags
exemplars_jsonVARCHARExemplars as JSON array
aggregation_temporalityINTEGERAggregation temporality (1=delta, 2=cumulative; 0=unspecified, also used for any out-of-spec value)

Exponential Histogram Metrics (read_otlp_metrics_exp_histogram)

27 columns total:

ColumnTypeDescription
time_unix_nanoTIMESTAMP_NSData point timestamp
start_time_unix_nanoTIMESTAMP_NSStart time
nameVARCHARMetric name
descriptionVARCHARMetric description
unitVARCHARMetric unit
countBIGINTTotal count of observations
sumDOUBLESum of all observations (optional)
minDOUBLEMinimum observed value (optional)
maxDOUBLEMaximum observed value (optional)
scaleINTEGERScale factor for bucket boundaries
zero_countBIGINTCount of observations at zero
zero_thresholdDOUBLEBoundary for zero bucket (optional)
positive_offsetINTEGERStarting index for positive buckets
positive_bucket_countsBIGINT[]Positive bucket counts (array of integers)
negative_offsetINTEGERStarting index for negative buckets
negative_bucket_countsBIGINT[]Negative bucket counts (array of integers)
service_nameVARCHARService name from resource attributes
service_namespaceVARCHARService namespace from resource attributes
service_instance_idVARCHARService instance ID from resource attributes
resource_attributesVARCHARResource attributes as JSON string
scope_nameVARCHARInstrumentation scope name
scope_versionVARCHARInstrumentation scope version
scope_attributesVARCHARScope attributes as JSON string
metric_attributesVARCHARData point attributes as JSON string
flagsINTEGERData point flags
exemplars_jsonVARCHARExemplars as JSON array
aggregation_temporalityINTEGERAggregation temporality (1=delta, 2=cumulative; 0=unspecified, also used for any out-of-spec value)

Type system notes

  • trace_id and span_id are VARCHAR hex strings. Use unhex() to convert to binary if needed.
  • Attribute columns store JSON strings. Parse with DuckDB’s JSON functions: json_extract(resource_attributes, '$.key'). For attributes you filter on often, the live server can promote resource/scope keys into dedicated columns at ingest — see Attribute promotion.
  • Timestamps: file readers expose nanosecond timestamp columns such as time_unix_nano and start_time_unix_nano as TIMESTAMP_NS. Live ingest tables keep the same column names but store those values as DuckDB TIMESTAMP for catalog compatibility.
  • Events and links are stored as JSON arrays in events_json and links_json.

For task-oriented queries and exports, use the how-to guides.

Live Ingest Server

You can run an embedded server that accepts live OpenTelemetry exports and streams them into DuckDB. Point any OpenTelemetry exporter at the server. The server buffers rows, then commits them in batches to the connection’s default catalog, a DuckLake lakehouse, or another attached writable catalog such as an Iceberg REST catalog.

The server speaks three wire protocols across two scheme-bound functions:

FunctionSchemeTransportWire protocol
otlp_serve (default)otlp: (port 4318)HTTPOTLP/HTTP (JSON, NDJSON, protobuf)
otlp_serve(transport := 'grpc')otlp:gRPCOTLP/gRPC unary Export
otap_serveotap: (port 4317)gRPCOTAP/Arrow bidirectional streaming

All three share one buffering/seal core, the same parameters, catalog targeting, token auth, and lifecycle functions — only the wire differs. The transport is not encoded in the scheme: otlp_serve picks HTTP vs gRPC via the transport parameter, and otap_serve is always gRPC. Each function rejects the other’s scheme.

A server is one ingest pipeline — one set of in-memory buffers, one admission cap, one writer, and one catalog-maintenance schedule — fed by one or more listeners. Pass a list of URIs to start several listeners on one server, for example OTLP/HTTP and OTLP/gRPC together:

SELECT listen_uri, transport
FROM otlp_serve(['otlp:localhost:4318', 'otlp:localhost:4317'], transport := ['http', 'grpc'],
                catalog := 'lake', token := 'my-dev-token-123456');

Each catalog target (catalog + schema, or Parquet export root) has at most one server, so it has a single writer. A second otlp_serve/otap_serve call for a target that already has a server fails; list every URI in one call instead.

Native extension builds include the server; WASM builds omit it entirely (no HTTP and no gRPC). See gRPC transport for the OTLP/gRPC and OTAP/Arrow service contracts.

For a runnable walkthrough, see the Live Ingest Quickstart. For lakehouse examples, see Stream to Local DuckLake, Stream to Remote DuckLake, Stream to Amazon S3 Tables, and Stream to Cloudflare R2 Data Catalog. For plain files or object storage, see Stream to Parquet. For the implementation model, see Architecture.

Command-line interface

The daemon ships as duckdb-otlp, a CLI for macOS and Linux that also converts OTLP/OTAP files, exports the catalog, and runs one-shot SQL. A bare invocation starts a local receiver with no configuration at all. See the CLI Reference for the full command, flag, and environment-variable surface; this page documents the SQL functions underneath it.

duckdb-otlp                                  # OTLP/HTTP 4318 + OTLP/gRPC 4317 on loopback
duckdb-otlp --host 0.0.0.0 --token "$TOKEN"  # a non-loopback bind requires a token

Docker daemon transports

The image starts OTLP/HTTP on 0.0.0.0:4318 (DUCKDB_OTLP_HTTP_PORT=4318). Each port setting selects its listener; 0 turns one off:

SettingListener
--http PORT / DUCKDB_OTLP_HTTP_PORTOTLP/HTTP
--grpc PORT / DUCKDB_OTLP_GRPC_PORTStandard OTLP/gRPC
--otap PORT / DUCKDB_OTLP_OTAP_PORTOTAP/Arrow (cannot be combined with the two above)

All of them bind --host / DUCKDB_OTLP_HOST. For example, accept both protocols into the same local DuckLake:

docker run --rm -p 4317:4317 -p 4318:4318 \
  -e DUCKDB_MODE=local-ducklake \
  -e DUCKDB_OTLP_GRPC_PORT=4317 \
  -e DUCKDB_OTLP_TOKEN=replace-with-a-private-token \
  -v otlp-data:/data ghcr.io/smithclay/duckdb-otlp:latest

Both listeners feed one server: the same catalog, schema, bearer token, buffers, writer, and maintenance schedule. DUCKDB_OTLP_MAX_BUFFERED_BYTES and DUCKDB_OTLP_SEAL_TARGET_BYTES apply to the whole process, not to each listener. Startup must succeed for every listener. On shutdown the daemon stops every listener, then drains the shared buffers once. If a later listener cannot start, the earlier ones are closed and the daemon exits with an error. Two listeners on the same port are rejected.

The image’s doctor command (also accepted as healthcheck) checks every enabled listener, using HTTP /readyz for HTTP and TCP connect for gRPC. A TCP check confirms a bound socket, not successful ingestion or durable writes. Because the listeners share one server, the HTTP /readyz reports the commit health of rows from both transports. DUCKDB_OTLP_HTTP_THREADS applies only to the HTTP listener. Quack remains a separate opt-in administrative endpoint.

For Cloud Run, set DUCKDB_OTLP_GRPC_PORT and DUCKDB_OTLP_HTTP_PORT=0, expose its port as h2c, and use a compatible probe instead of HTTP /readyz on that port. Cloud Run terminates TLS and forwards cleartext HTTP/2 to the container. Its single ingress port does not expose both daemon ports; running both does not multiplex the protocols onto one port. See Cloud Run HTTP/2 configuration.

Functions

The extension registers six server functions (two to start a server, two lifecycle, two diagnostic):

FunctionWhat it does
otlp_serve([uri], ...)Start an OTLP server (OTLP/HTTP, or OTLP/gRPC with transport := 'grpc') on one or more listeners and create/validate target tables. Returns one row per listener.
otap_serve([uri], ...)Start an OTAP/Arrow gRPC streaming server and create/validate target tables. Same parameters and output as otlp_serve. Returns one row per listener.
otlp_flush(uri)Force a synchronous commit of buffered rows when readers need fresh data. Returns commit stats. It leaves catalog maintenance alone.
otlp_stop(uri)Stop the server that owns listener uri, including its other listeners (commits remaining rows first). Returns a status string.
otlp_stop()Stop every server on this database, committing each first. Returns one row per server.
otlp_server_list()List every running listener with its server’s live counters, buffer state, and health.
otlp_seal_list()List recent seal attempts with append, commit, row, byte, and error telemetry.

otlp_flush, otlp_stop, otlp_server_list, and otlp_seal_list are transport-agnostic — they dispatch by the scheme-aware canonical listen URI, so an otap: server and an otlp: server are distinct entries managed by the same lifecycle functions. Any listener’s URI names its whole server.

otlp_serve([uri], ...)

Starts an OTLP ingest server with a listener on uri. The uri argument is optional; with no argument it defaults to otlp:localhost:4318. Pass a VARCHAR[] list to start several listeners on the same server.

-- Stream into an attached catalog
SELECT * FROM otlp_serve('otlp:localhost:4318', catalog := 'lake', token := 'my-dev-token-123456');

Parameters:

ParameterTypeDefaultDescription
uri (positional)VARCHAR or VARCHAR[]otlp:localhost:4318Listen URI, or a list of distinct listen URIs that feed one server. See URI scheme.
transportVARCHAR or VARCHAR[]httphttp (OTLP/HTTP) or grpc (OTLP/gRPC unary). One value applies to every URI; a list must have one entry per URI. otap_serve accepts only grpc.
catalogVARCHAR(default catalog)Name of the target catalog. Empty means the connection’s default catalog (in-memory or file). Set this to an attached writable catalog such as DuckLake or an Iceberg REST catalog to stream OTLP into a lakehouse. See Catalog targeting.
tokenVARCHAR(random, see below)Auth token clients must present. Must be at least 16 characters. If you omit it, otlp_serve generates a random 32-hex-character token and returns it in auth_token. Ignored when disable_auth := true.
disable_authBOOLEANfalseAccept every request without checking the token. No token is generated or validated, and auth_token comes back empty. Opt-in for trusted local networks and for producers that cannot attach a bearer token (e.g. the otel-arrow OTAP exporter). See Authentication.
schemaVARCHARmainSchema (within the catalog) that holds the target tables.
parquet_export_pathVARCHAR(none)Plain Parquet export root. When set, each seal writes the sealed rows to <root>/<table>/year=YYYY/month=MM/day=DD/*.parquet as the only durable store (no local table copy); a read-only view per signal is created over the files for inspection (see parquet_views). Mutually exclusive with a catalog target. Export is at-least-once (a COPY cannot be rolled back).
parquet_viewsBOOLEANtrueWith parquet_export_path: create the read-only inspection view for each signal after its first export. Creating a view reads the footer of every file already in that signal’s dataset, so it happens at most once per server and is skipped when the schema already holds that name. Set false when nothing reads the views. The duckdb-otlp daemon passes false unless Quack is enabled.
create_tablesBOOLEANtrueCreate the six target tables if they don’t exist. When false, the tables must already exist with the expected columns or otlp_serve fails fast.
allow_other_hostnameBOOLEANfalseAllow binding to a non-localhost host. By default otlp_serve permits only localhost, 127.0.0.1, and ::1.
max_body_bytesUBIGINT16777216 (16 MiB)Reject request bodies larger than this with 413. Must be greater than zero.
http_threadsUBIGINThost-based bounded defaultWorker threads for concurrent HTTP requests, per HTTP listener. Must be greater than zero when set.
max_buffered_bytesUBIGINT536870912 (512 MiB)Backpressure cap for the whole server, shared by every listener. Requests that would exceed it return 503 (gRPC: RESOURCE_EXHAUSTED).
seal_target_bytesUBIGINT134217728 (128 MiB)Request an asynchronous seal when admitted, uncommitted request bytes reach this threshold. Larger values write fewer, larger files at the cost of a larger in-memory crash-loss window (still bounded by seal_max_age_ms). Must be greater than zero.
seal_max_age_msBIGINT5000Request an asynchronous seal when the oldest buffered row reaches this age. Must be greater than zero.
target_file_sizeUBIGINT268435456 (256 MiB)DuckLake only. Output Parquet file size the post-seal CHECKPOINT merge bin-packs toward; bounds compaction write amplification (files already at target are left alone). Distinct from seal_target_bytes, which is admitted input bytes. Must be greater than zero.
maintenance_retention_msBIGINT900000 (15 min)DuckLake only. How old snapshots and unused data files must be before the post-seal CHECKPOINT expires and deletes them (expire_older_than / delete_older_than), and how old an untracked data file must be before the orphan sweep deletes it. Keep it longer than your longest read; time-travel below this window is unavailable. Must be greater than zero.
maintenance_interval_msBIGINT300000 (5 min)Named catalogs only. The most often the background writer runs CHECKPOINT <catalog>; it runs only after rows were committed since the last attempt. Must be greater than zero.
promote_resource_attributesVARCHAR(none)Comma-separated resource attribute keys to promote into first-class columns at ingest. See Attribute promotion. Catalog mode only.
promote_scope_attributesVARCHAR(none)Comma-separated scope attribute keys to promote into first-class columns at ingest. See Attribute promotion. Catalog mode only.

Output columns (one row per listener):

ColumnTypeDescription
listen_uriVARCHARThe otlp: URI the listener is bound to.
listen_urlVARCHARThe equivalent http:// base URL (POST endpoints hang off this).
auth_tokenVARCHARThe token clients must present (the value you passed, or the generated one).
schema_nameVARCHARSchema holding the target tables.
logs_tableVARCHARotlp_logs
traces_tableVARCHARotlp_traces
metrics_gauge_tableVARCHARotlp_metrics_gauge
metrics_sum_tableVARCHARotlp_metrics_sum
metrics_histogram_tableVARCHARotlp_metrics_histogram
metrics_exp_histogram_tableVARCHARotlp_metrics_exp_histogram
catalog_nameVARCHARTarget catalog. Empty for the connection’s default catalog.
transportVARCHARhttp or grpc.

Starting a second server on the same URI, or for the same catalog target, fails (OTLP server already exists). If any listener fails to bind, the listeners already started are closed and no server is registered. The DuckDB DatabaseInstance owns the server lifetime: DuckDB stops all servers when the database closes, but it does not commit their buffers at that point (see Durability below). Call otlp_stop before closing the database to avoid losing buffered rows — otlp_stop() with no argument covers every server, including any you did not start yourself.

otap_serve([uri], ...)

Starts an OTAP/Arrow gRPC streaming server bound to uri. The uri argument is optional; with no argument it defaults to otap:localhost:4317. otap_serve is gRPC-only — transport must be 'grpc' or omitted (OTAP/Arrow is always gRPC); any other value is rejected.

-- Stream OTAP/Arrow into an attached DuckLake catalog
SELECT listen_uri, listen_url FROM otap_serve('otap:localhost:4317', catalog := 'lake', token := 'my-dev-token-123456');

It takes the same named parameters and returns the same output columns as otlp_serve; only the transport, scheme, and default port differ. It serves the canonical OTAP/Arrow bidirectional-streaming services (Arrow{Logs,Traces,Metrics}Service) for all six signals, sharing the same catalog/Parquet targeting, token auth, buffered group-commit, and lifecycle functions. See gRPC transport for the service and RPC contract.

Two parameter notes for the gRPC path:

  • max_body_bytes becomes the gRPC server’s maximum decoding message size (the largest single BatchArrowRecords/Export message accepted), rather than an HTTP body cap.
  • http_threads is ignored — it tunes only the HTTP worker pool; the gRPC path uses its own async runtime.

Because the wire is gRPC (HTTP/2), an otap: server exposes no HTTP endpoints — the /v1/* POST paths and the /healthz / /readyz probes are HTTP-only. The listen_url output column is still populated with a derived http://host:port string for display, but it is not a usable HTTP base URL; clients connect with a gRPC client, and a liveness probe should use a TCP connect rather than /readyz. The same applies to an otlp_serve(transport := 'grpc') listener.

otlp_flush(uri)

Forces a synchronous commit: the server writes its in-memory buffer to the target in one transaction before the function returns. Normal ingest can rely on background commits, and otlp_stop performs a final commit. Use otlp_flush when readers need the latest accepted rows while the server stays running. otlp_flush handles durability and read freshness; it leaves compaction and other catalog maintenance alone.

-- Force a commit
SELECT * FROM otlp_flush('otlp:localhost:4318');

Parameters:

ParameterTypeDefaultDescription
uri (positional)VARCHAR(required)Listen URI of the server to flush.

Output columns (one row):

ColumnTypeDescription
statusVARCHARsealed on success, or No server found listening on <uri>. The literal success value means the batch commit completed.
sealed_rowsUBIGINTRows committed by this call.
seals_totalUBIGINTTotal batch commits performed by this server since startup.
errorVARCHARCommit error detail, or NULL if none.

otlp_stop(uri)

Stops the server that owns listener uri: every listener of that server stops accepting and frees its port, then the shared buffers are committed once, so a graceful stop loses no data.

SELECT status FROM otlp_stop('otlp:localhost:4318');

otlp_stop()

Stops every server on this database, committing each one before returning, and returns one row per server. The registry stays usable afterwards: this is a graceful drain, not teardown, so a later otlp_serve still works.

SELECT status, dropped_rows FROM otlp_stop();

Prefer this over otlp_stop(uri) in a shutdown path. A stop that names one URI reaches only that server, so a server started somewhere else — by another connection, or by the daemon’s --init-sql script — survives to database teardown, where the final commit can no longer write and its buffered rows are dropped. With no servers running it returns a single No OTLP servers are running row.

Output columns (both forms):

ColumnTypeDescription
statusVARCHARStopped listening on <uri>[, <uri>...] listing every listener that was stopped, or No server found listening on <uri> if none matched.
dropped_rowsUBIGINTRows still buffered after the final commit failed, and therefore lost. 0 on a clean stop.

otlp_server_list()

Lists running listeners with their server’s live counters and buffer state. Takes no arguments. Listeners of the same server report identical buffer, seal, and maintenance values; listen_uri, transport, is_listening, and last_error are per listener.

SELECT
  listen_uri,
  catalog_name,
  total_rows,
  buffered_rows,
  last_seal_age_ms AS last_commit_age_ms,
  is_listening
FROM otlp_server_list();

Output columns (one row per listener):

ColumnTypeDescription
listen_uriVARCHARThe otlp: listen URI.
listen_urlVARCHARThe http:// base URL.
hostVARCHARBound host.
portUSMALLINTBound port.
catalog_nameVARCHARTarget catalog. Empty for the default catalog.
schema_nameVARCHARSchema holding the target tables.
active_requestsUBIGINTRequests in progress.
total_requestsUBIGINTRequests handled since startup (includes failures).
total_rowsUBIGINTRows accepted (buffered) since startup. Once the buffer drains, this equals the rows committed. A /v1/metrics request counts rows across all four metric tables.
buffered_rowsUBIGINTRows in the buffer that the writer has not committed.
admitted_bytesUBIGINTEncoded request bytes admitted but not yet released by a successful seal.
buffered_bytesUBIGINTApproximate decoded heap held by the in-memory buffers. Unlike admitted_bytes (which bounds encoded input via max_buffered_bytes), this reflects the real memory footprint and grows unbounded while a seal is stuck — watch it to detect backpressure-vs-OOM risk.
seal_target_bytesUBIGINTConfigured size trigger for requesting a seal.
seal_max_age_msBIGINTConfigured age trigger for requesting a seal.
oldest_buffered_age_msBIGINTAge (ms) of the oldest buffered row, or NULL when empty.
last_seal_age_msBIGINTAge (ms) since the last successful batch commit, or NULL if none has completed.
seals_totalUBIGINTBatch commits performed since startup.
committed_rows_totalUBIGINTRows committed since startup.
seal_failures_totalUBIGINTFailed batch commits since startup.
is_listeningBOOLEANfalse once the listener has fallen over (e.g. an error after a successful bind).
last_errorVARCHARLast fatal listener error, or NULL if none.
seal_last_errorVARCHARLast batch commit error, or NULL if none.
maintenance_runs_totalUBIGINTSuccessful post-seal catalog maintenance (CHECKPOINT) passes since startup. Stays 0 for the default catalog and for catalogs where maintenance is unsupported/disabled.
maintenance_failures_totalUBIGINTFailed maintenance passes since startup. Excludes contended passes.
last_maintenance_age_msBIGINTAge (ms) since the last successful maintenance pass, or NULL if none has run.
maintenance_last_errorVARCHARLast maintenance error, or NULL if none.
promoted_columns_totalUBIGINTPromoted attribute columns per signal table, or 0 when attribute promotion is off/disabled.
transportVARCHARThe listener’s transport: http or grpc.
maintenance_contended_totalUBIGINTMaintenance passes skipped because another writer checkpointed the same catalog first (for example a second receiver process). Not a failure.

Use is_listening / last_error to detect a dead listener. Use seal_last_error to inspect writer failures, such as catalog conflicts. Use maintenance_runs_total / last_maintenance_age_ms to confirm compaction is keeping up.

otlp_seal_list()

Lists the bounded in-memory history of recent seal attempts for all running servers. duration_ms covers the complete seal attempt. For transaction-backed targets, append_duration_ms measures appending buffered chunks into the destination tables and commit_duration_ms measures COMMIT, including catalog and object-storage work. The remaining duration is buffer swapping, transaction setup, and bookkeeping. Plain Parquet export does not have a transaction commit, so both phase fields are zero.

Catalog targeting

The target of a server is <catalog>.<schema>.<table>. The live-ingest tables keep the same column names as the file readers, but the nanosecond timestamp columns (time_unix_nano, start_time_unix_nano, …) are stored as DuckDB TIMESTAMP (microsecond) for catalog compatibility, where the file readers expose TIMESTAMP_NS — so a query that mixes a live table with read_otlp_* sees two types and loses sub-microsecond precision on the live side (see the Schema Reference).

  • Default catalog (catalog omitted): rows land in the connection’s default catalog, either an in-memory database or the file you opened DuckDB with. Use this zero-setup path when you do not need a lakehouse catalog. The server still buffers ingest (a POST returns 202); rows become durable in that database at the next background commit.
  • DuckLake catalog (catalog := '<attached_db>'): rows stream into a DuckLake lakehouse with Parquet data files on local or object storage, tracked by a catalog. Attach the catalog first, then name it:
INSTALL ducklake; LOAD ducklake;
ATTACH 'ducklake:metadata.ducklake' AS lake (DATA_PATH 'otlp_data/');

CALL otlp_serve('otlp:localhost:4318', catalog := 'lake');
-- rows buffer and commit into Parquet under otlp_data/
SELECT count(*) FROM lake.main.otlp_logs;

Each batch commit writes one Parquet data file per signal plus one DuckLake snapshot. At most once per maintenance_interval_ms (5 minutes by default), and only when rows were committed since the last attempt, duckdb-otlp runs best-effort catalog-native maintenance with DuckDB’s non-force CHECKPOINT lake. On a DuckLake catalog, CHECKPOINT merges adjacent files and expires/cleans old snapshots and data files in one pass — turning the many small per-seal files into compacted, query-efficient files. At startup the server sets the DuckLake options CHECKPOINT reads so this is bounded: target_file_size caps the merge output (files already at target are left alone, so re-compaction is O(new), not O(total)), and expire_older_than / delete_older_than (from maintenance_retention_ms) gate how old snapshots/files must be before reclaim. See Durability and background commits.

Several processes can share one DuckLake catalog (for example two receiver instances during a deploy). Their CHECKPOINTs can race: the loser fails with a catalog error such as PostgreSQL’s could not serialize access due to concurrent delete. The server counts that as contention, not failure: it increments maintenance_contended_total, leaves maintenance_failures_total and maintenance_last_error alone, and tries again at the next interval. The losing checkpoint can leave a Parquet file the catalog never tracked. After each successful CHECKPOINT on a DuckLake catalog, the server runs ducklake_delete_orphaned_files with older_than set to maintenance_retention_ms, so it removes those files but never a file a seal or checkpoint may still be writing.

DuckLake inlines small inserts: rows below its data-inlining row limit are stored in the catalog database (for example PostgreSQL) instead of a Parquet file, and only CHECKPOINT flushes them to Parquet. At low volume, most seals are inlined, so no Parquet appears until the next maintenance pass. The time-based trigger bounds that delay. The daemon also prints each CHECKPOINT success and failure to stderr. To skip inlining entirely, attach with DATA_INLINING_ROW_LIMIT 0. The daemon does this when DUCKLAKE_DATA_INLINING_ROW_LIMIT=0 is set, and every seal then writes Parquet directly, at the cost of one small file per signal per seal until compaction.

  • Iceberg REST catalog (catalog := '<attached_db>'): rows stream into tables in an attached writable Iceberg REST catalog. Attach the catalog with DuckDB’s iceberg extension, create the target schema, then pass the catalog and schema to otlp_serve; see Stream to Amazon S3 Tables and Stream to Cloudflare R2 Data Catalog for managed provider paths. DuckDB’s Iceberg REST catalog docs have no useful CHECKPOINT maintenance path today. The internal maintenance probe uses generic CHECKPOINT <catalog> only. If the catalog reports checkpointing as unsupported, the server disables automatic maintenance for that server and ingest durability continues normally.

  • Plain Parquet export (parquet_export_path := '/data/otlp-parquet' or parquet_export_path := 's3://bucket/prefix'): each seal writes the sealed rows straight to <path>/<table>/year=YYYY/month=MM/day=DD/*.parquet. The Parquet dataset is the only durable store — no local table copy is kept (a read-only view per signal is created over the files for inspection), and it is mutually exclusive with a catalog target. Because a COPY is a file write and cannot be rolled back, export is at-least-once: a signal that already exported is never re-written, but a seal whose COPY fails part-way can re-export that signal’s rows on retry, so deduplicate downstream if you need exactly-once. Use this when you want partitioned Parquet without a lakehouse catalog; see Stream to Parquet.

Attribute promotion

Resource and scope attributes land as JSON objects in the resource_attributes and scope_attributes columns (see Schemas), so filtering one means a full-scan json_extract_string(...) with no row-group pruning. Attribute promotion lifts operator-named keys out of that JSON into their own top-level columns at ingest, so the scanner gets per-row-group min/max statistics and can skip files. It is the right tool for the low-cardinality, stable identity attributes you filter and group by most — service.name is already a column, but deployment.environment, k8s.namespace.name, cloud.region, and the like are not.

SELECT * FROM otlp_serve(
    'otlp:0.0.0.0:4318',
    catalog := 'lake',
    promote_resource_attributes := 'deployment.environment, k8s.namespace.name',
    promote_scope_attributes    := 'telemetry.sdk.name'
);
  • Column naming. Each key becomes resource_attr_<key> or scope_attr_<key> (non-alphanumeric characters become _), e.g. deployment.environment → resource_attr_deployment_environment, on all six signal tables. The columns are added once when the server starts.

  • The JSON blob is kept. A promoted column is an accelerator, not a replacement — the original key stays in resource_attributes/scope_attributes. Rows written before a key was promoted read back NULL for its column, so query across old and new data with:

    COALESCE(resource_attr_deployment_environment,
             json_extract_string(resource_attributes, '$."deployment.environment"'))
    
  • No auto-discovery. The promoted set is exactly what you list — there is no workload observation or automatic promotion.

  • Catalog mode only. Promotion adds real columns via ALTER TABLE, so it requires a catalog target (DuckLake). It is ignored under parquet_export_path. On an Iceberg REST catalog it works only if the catalog supports ADD COLUMN; otherwise the server logs a warning and disables promotion (ingest continues).

  • Type. Promoted columns are VARCHAR (the JSON-extracted text).

  • otlp_server_list().promoted_columns_total reports the promoted column count per signal.

The daemon exposes the same option via DUCKDB_OTLP_PROMOTE_RESOURCE_ATTRIBUTES and DUCKDB_OTLP_PROMOTE_SCOPE_ATTRIBUTES (comma-separated). The daemon image must have the json extension available; if it cannot load it, promotion disables itself with a log.

URI scheme

The scheme binds the URI to a serve function (no mixing): otlp: is otlp_serve, the OTLP server (OTLP/HTTP by default on port 4318, or OTLP/gRPC unary with transport := 'grpc'); otap: is otap_serve, the OTAP/Arrow gRPC server (port 4317). Each function rejects the other’s scheme.

FormExampleServer
otlp:host:portotlp:localhost:4318OTLP/HTTP (or OTLP/gRPC with transport := 'grpc')
otlp://host:portotlp://127.0.0.1:4318OTLP/HTTP
otap:host:portotap:localhost:4317OTAP/Arrow (gRPC)
IPv6 (host in brackets)otlp:[::1]:4318OTLP/HTTP

The scheme is part of the canonical key, so otap:host:4317 and otlp:host:4318 are distinct servers in otlp_server_list / otlp_stop / otlp_flush. By default, otlp_serve/otap_serve allow only localhost, 127.0.0.1, and ::1. To bind to any other host (for example 0.0.0.0 to accept remote exporters), pass allow_other_hostname := true; non-localhost hosts are rejected before a socket is bound.

The scalar function otlp_uri_parser(uri) parses an otlp:/otap: URI and returns a STRUCT(host VARCHAR, port USMALLINT, ipv6 BOOLEAN, url VARCHAR) — the same parsing the serve functions use, useful for validating a URI up front.

HTTP endpoints

The http:// base URL from listen_url exposes:

MethodPathDescription
POST/v1/logsIngest logs into otlp_logs.
POST/v1/tracesIngest traces into otlp_traces.
POST/v1/metricsIngest metrics. Fans out across all four metric tables: otlp_metrics_gauge, otlp_metrics_sum, otlp_metrics_histogram, otlp_metrics_exp_histogram.
GET/healthzLiveness probe. Returns 200 with {"status":"ok"}. No auth required.
GET/readyzReadiness probe. Returns 200 with {"status":"ready"} once the listener is bound, and 503 with {"status":"degraded"} when buffered rows are not committing (a seal has failed, rows are still buffered, and the last successful seal is absent or several seal cycles old). No auth required.

Tables live in <catalog>.<schema>, chosen by otlp_serve(catalog := ..., schema := ...).

Content types

The server picks a parser from the request Content-Type:

Content-TypeFormat
application/json, application/otlp+jsonOTLP/JSON
application/x-ndjsonnewline-delimited OTLP/JSON (JSONL)
application/x-protobuf, application/protobuf, application/otlpOTLP/protobuf

Any other content type returns 415.

Content encodings

Content-Encoding: identity (or no header), gzip, and deflate are accepted. Any other content encoding returns 415.

Authentication

Every POST must present the configured token through one of these headers:

  • Authorization: Bearer <token> (case-insensitive scheme)
  • x-api-key: <token>

The server checks the two headers independently, so a malformed Authorization header does not mask a valid x-api-key. A missing or invalid token returns 401. The server compares tokens with a constant-time check.

Tokens must be at least 16 characters. Auto-generated tokens (when token is omitted) are 32 hex characters (128 bits of entropy).

Disabling authentication

disable_auth := true turns auth off entirely: the server accepts every request without checking any header, mints no token, and returns an empty auth_token. The same flag applies to the gRPC transports (otlp_serve(transport := 'grpc') and otap_serve), which otherwise reject a bad token with UNAUTHENTICATED.

This exists for two cases: trusted, network-isolated deployments, and OTLP/OTAP producers that have no way to attach a bearer token — notably the otel-arrow OTAP exporter, which has no header/auth configuration. It is off by default; only enable it when the listener is otherwise protected (loopback bind, private network, or a sidecar that terminates auth), since anyone who can reach the port can write to your tables.

gRPC transport

There are two gRPC entry points, each bound to its own scheme and serving a disjoint service family, for all six signals:

  • otlp_serve('otlp:...', transport := 'grpc') — standard OTLP/gRPC unary Export. otlp_serve defaults to otlp:localhost:4318 (HTTP); point it at the conventional gRPC port for this, e.g. otlp:localhost:4317.
  • otap_serve('otap:...') — canonical OTAP/Arrow bidirectional streaming. Defaults to otap:localhost:4317; gRPC-only.

Both share everything below the wire: the same parameters, catalog/Parquet targeting, token auth, buffered group-commit (“seal”) path, backpressure cap, and lifecycle functions (otlp_flush / otlp_stop / otlp_server_list / otlp_seal_list). Because the service sets are disjoint, calling the other family on a listener returns UNIMPLEMENTED.

ServerServiceRPCWire format
otlp_serve(transport := 'grpc')opentelemetry.proto.collector.{logs,trace,metrics}.v1.{Logs,Trace,Metrics}ServiceExport (unary)Standard OTLP/gRPC
otap_serveopentelemetry.proto.experimental.arrow.v1.Arrow{Logs,Traces,Metrics}ServiceArrow{Logs,Traces,Metrics} (bidirectional streaming)OTAP/Arrow (stream BatchArrowRecords → stream BatchStatus)

Notes:

  • Auth is the bearer token in the gRPC authorization metadata (Bearer <token>); a bad token is rejected with UNAUTHENTICATED, unless disable_auth is set. Backpressure surfaces as RESOURCE_EXHAUSTED (the gRPC equivalent of HTTP 503), a batch that fails to convert as INVALID_ARGUMENT (HTTP 400), and a server-side failure as INTERNAL (HTTP 500, also written to duckdb_logs).
  • OTAP streaming keeps one stateful decoder per stream, so later messages can reuse the Arrow dictionaries/schemas established by earlier ones. The server returns one BatchStatus per received BatchArrowRecords. A message that fails to decode is nacked and the stream is closed (the decoder is poisoned); a message nacked for backpressure leaves the stream open.
  • Metrics decode into up to four shapes per message, each buffered independently — a backpressure nack partway through a metrics message can leave earlier shapes buffered.
  • The gRPC stack (tokio + tonic) is statically linked into the extension; it adds no new shared-library dependencies and, like the HTTP server, is native-only (absent from WASM builds).

Responses and status codes

A successful POST returns 202 Accepted after the server buffers rows:

{"status":"buffered","rows":42,"batches":1}

A 202 means the server validated, converted, and accepted the rows into the in-memory buffer. The rows are not yet durable (see below).

Errors return JSON shaped like {"error":"<reason>","message":"<detail>"}:

StatusWhen
400OTLP body failed to parse (or other invalid input).
401Missing or invalid auth token.
413Body larger than max_body_bytes.
415Unsupported Content-Type or Content-Encoding.
503Buffer admission full (request would exceed max_buffered_bytes). Retry with backoff.
500Internal error (also written to duckdb_logs).

Durability and background commits

The server buffers ingest and commits rows in batches for each target. Batch commits avoid per-request tiny files and write conflicts: a single serialized writer prevents concurrent catalog writes from the ingest server.

The flow:

  1. A POST reserves admission bytes, parses, converts, and appends rows into the relevant per-signal in-memory buffer, then returns 202. The bounded worker pool does this concurrently; append locks only the target signal buffer.
  2. A single background writer commits the buffer to the target in one transaction when any trigger fires:
    • admitted request-body bytes reach the internal size threshold, 128 MiB today,
    • the oldest buffered row reaches the internal age limit, about 5 seconds today, or
    • an explicit otlp_flush.
  3. For a DuckLake target, each batch commit writes one Parquet data file per signal plus one snapshot.
  4. For named catalogs, the writer runs best-effort, non-force CHECKPOINT <catalog> outside the ingest transaction at most once per maintenance_interval_ms, when rows were committed since the last attempt. The server skips the default catalog, explicit otlp_flush, and shutdown drains; unsupported checkpoint implementations log once and disable maintenance for that server. While a checkpoint runs, commits wait for it and ingest keeps buffering against max_buffered_bytes.

Durability contract:

  • A 202 is not durable. Rows become durable at the next background commit, on otlp_stop, or on otlp_flush.
  • A crash or hard kill loses buffered-but-uncommitted rows (at-most-once for that window).
  • otlp_stop and otlp_flush commit remaining rows before returning, so those calls lose no accepted rows. A plain database/connection close does NOT commit buffered rows. The drain runs after DuckDB tears down the instance, when it can no longer write, so DuckDB can drop buffered rows. Prefer otlp_stop before closing the database. Use otlp_flush when the server should keep running but readers need durable rows now.

The project tracks a future durable raw-spool journal for at-least-once delivery.

Backpressure: if admitting a request would exceed max_buffered_bytes (default 512 MiB) across in-flight and uncommitted accepted payloads, the POST returns 503 before parse/transform work. Clients should retry with backoff.

Seal cadence: seal_target_bytes and seal_max_age_ms are size and age triggers for the single asynchronous writer. They control batching latency and file/transaction size; they do not raise durable write throughput. max_buffered_bytes remains the separate admission cap.

Keeping DuckLake tidy: each batch commit leaves one Parquet file per signal, so a high seal cadence creates many small files. For DuckLake, the periodic CHECKPOINT merges those into larger files and reclaims old snapshots/files. The merge is bounded by the target_file_size option the server sets at startup (files already at target are skipped, so re-compaction cost scales with new data, not total data), and reclaim is gated by maintenance_retention_ms (expire_older_than / delete_older_than). Maintenance stays outside the ingest transaction; a maintenance failure leaves committed rows intact. otlp_flush still forces only ingest durability and leaves compaction to catalog maintenance.

Concurrency model

  • The server runs a bounded httplib worker pool. Workers parse, convert, and buffer requests concurrently; each signal table has its own buffer lock. In the daemon, set DUCKDB_OTLP_HTTP_THREADS to override the host-based default.
  • A single background writer thread writes to the target catalog. Serial writes let DuckLake, which uses optimistic concurrency, avoid conflict retries and tiny-file churn.

Verifying ingest under load

make test cannot issue HTTP POSTs, so the SQL logic tests cover only the lifecycle functions. The ingest path is tested against the real daemon in test/server/, which CI runs on every pull request: auth (bearer and x-api-key), content-type and content-encoding handling, 413, 503 backpressure, the metrics fan-out, OTLP/HTTP and OTLP/gRPC, OTAP/Arrow streams with dictionary reuse, and the drain on SIGTERM. test/cpp/test_seal_harness.cpp drives the seal path directly: failure and re-buffer, Parquet partial exports, catalog maintenance, and promoted columns.

DUCKDB_OTLP_SERVER_BIN=build/release/extension/otlp/duckdb-otlp \
  uv run --with pytest --with grpcio --with opentelemetry-proto --with duckdb==2.0.0 pytest test/server

See also

Error Reference

The file readers fail fast on malformed OTLP input. Errors identify file discovery problems, payload shape mismatches, file size limits, and unsupported metric shapes. Live ingest reports authentication, request, and backpressure failures through HTTP or gRPC status codes.

File reader errors

No files matched the path or glob

SELECT * FROM read_otlp_logs('missing/*.jsonl');
-- No files found that match the pattern

The path is resolved from DuckDB’s working directory. An absolute path avoids working-directory ambiguity.

Malformed OTLP input

SELECT * FROM read_otlp_traces('malformed.jsonl');
-- OTLP parse error on malformed.jsonl: ...

The top-level payload field must match the reader:

ReaderRequired payload field
read_otlp_tracesresourceSpans
read_otlp_logsresourceLogs
read_otlp_metrics_*resourceMetrics

Unsupported metric shape

read_otlp_metrics() and read_otlp_metrics_summary() raise an unsupported-function error. The supported typed metric readers are:

SELECT * FROM read_otlp_metrics_gauge('metrics.jsonl');
SELECT * FROM read_otlp_metrics_sum('metrics.jsonl');
SELECT * FROM read_otlp_metrics_histogram('metrics.jsonl');
SELECT * FROM read_otlp_metrics_exp_histogram('metrics.jsonl');

File is too large

Each file is limited to 100 MB to bound memory use. Larger exports must be split, for example with the OpenTelemetry Collector file exporter’s rotation settings, and can then be queried through a glob.

Live ingest errors

otlp_serve returns HTTP errors as JSON. Common responses are:

StatusCondition
401 UnauthorizedThe bearer token is missing or invalid.
413 Content Too LargeThe request body exceeds max_body_bytes.
415 Unsupported Media TypeThe content type or content encoding is unsupported.
503 Service Unavailablemax_buffered_bytes backpressure rejects the request.

The Live Ingest Reference defines the complete HTTP and gRPC error contract.

Performance Tips

Use these rules before reaching for deeper tuning.

Prefer the Right Format

  • JSON/JSONL is easiest to inspect and works in WASM.
  • Protobuf is smaller; native builds parse it fastest in most workloads.
  • For repeated queries, convert OTLP exports to Parquet.
COPY (
  SELECT * FROM read_otlp_traces('traces/*.jsonl')
) TO 'warehouse/traces.parquet' (FORMAT PARQUET);

SELECT count(*)
FROM read_parquet('warehouse/traces.parquet')
WHERE duration_time_unix_nano > 1000000000;

Read Less Data

Project only the columns you need and avoid broad globs:

SELECT trace_id, name, duration_time_unix_nano
FROM read_otlp_traces('data/2026-05-30/*.jsonl')
WHERE service_name = 'api-gateway'
  AND duration_time_unix_nano > 1000000000;

The file readers support projection pushdown. They skip filter pushdown for OTLP scans today, so narrower files and Parquet conversion matter for large repeated scans.

Keep Files Reasonable

Individual file reads are capped at 100 MB. Configure collector rotation so files stay small:

rotation:
  max_megabytes: 50
  max_days: 1

Materialize Common Views

CREATE TABLE hourly_stats AS
SELECT
  date_trunc('hour', start_time_unix_nano) AS hour,
  service_name,
  count(*) AS span_count,
  avg(duration_time_unix_nano) / 1000000 AS avg_ms
FROM read_otlp_traces('traces/*.jsonl')
GROUP BY hour, service_name;

Promote Hot Attributes

Filtering an attribute that lives inside the resource_attributes / scope_attributes JSON blob is a full scan — json_extract_string(...) has no row-group statistics. If you repeatedly filter or group by a resource/scope attribute (deployment.environment, k8s.namespace.name, cloud.region, …), have the live server promote it into a real column at ingest so the scanner can prune by min/max:

SELECT * FROM otlp_serve('otlp:0.0.0.0:4318', catalog := 'lake',
    promote_resource_attributes := 'deployment.environment, k8s.namespace.name');

This trades a little ingest work for much cheaper repeated reads. See Attribute promotion.

Live Ingest

Live ingest buffers accepted rows and commits them in batches. Current native builds commit when the oldest buffered row is about 5 seconds old, or when admitted request-body bytes reach about 64 MiB. Use otlp_flush when readers need fresh rows while the server keeps running.

For named catalog targets, the writer runs best-effort catalog-native CHECKPOINT <catalog> outside the ingest transaction at most once per maintenance_interval_ms (5 minutes by default), after rows were committed. The writer skips the default catalog, explicit otlp_flush, and shutdown drains. While a checkpoint runs, commits wait and ingest keeps buffering against max_buffered_bytes, so size that cap for a few minutes of peak ingest. DuckLake uses this checkpoint hook for its own maintenance policy; the server logs unsupported catalog implementations and disables maintenance for that server. See Live Ingest Reference.

Architecture

This page describes the internal architecture of the DuckDB OpenTelemetry Extension.

Overview

The DuckDB OpenTelemetry Extension exposes typed readers for OpenTelemetry Protocol (OTLP) telemetry files. It reads traces, logs, and metrics from JSON and protobuf OTLP exports.

Extension Type

The extension includes:

  • Table functions: read_otlp_traces, read_otlp_logs
  • Metrics functions: read_otlp_metrics_gauge, read_otlp_metrics_sum, read_otlp_metrics_histogram, read_otlp_metrics_exp_histogram
  • Live ingest functions: otlp_serve (OTLP/HTTP, or OTLP/gRPC with transport := 'grpc'), otap_serve (OTAP/Arrow streaming), otlp_flush, otlp_stop, otlp_server_list, otlp_seal_list (native builds only). See Live Ingest Server
  • OTAP file readers: read_otap_traces, read_otap_logs, read_otap_metrics_gauge, read_otap_metrics_sum, read_otap_metrics_histogram, read_otap_metrics_exp_histogram — decode OTAP BatchArrowRecords files into the same schemas as the read_otlp_* readers

How It Works

OpenTelemetry     File        duckdb-otlp          SQL
Collector      Exporter       Extension          Results
   │              │               │                 │
   │  OTLP/gRPC   │               │                 │
   ├─────────────►│  .jsonl/.pb   │                 │
   │              ├──────────────►│  read_otlp_*()  │
   │              │               ├────────────────►│
   │              │               │                 │

The extension reads OTLP files (JSON or protobuf), detects the format, and streams typed rows into DuckDB tables. Schemas use snake_case names and follow the OpenTelemetry ClickHouse exporter shape.

Core Components

Rust Backend

Location: external/otlp2records

Parses OTLP JSON, JSONL, and protobuf payloads and emits Arrow arrays through the Arrow C Data Interface.

Arrow Import

Location: src/otlp_arrow.cpp, src/function/read_otlp.cpp

Hands the Rust backend’s Arrow arrays to DuckDB’s own Arrow importer. The extension asks otlp2records for its DuckDB Arrow profile, which already uses the column types the schemas promise (hex VARCHAR ids, a BIGINT nanosecond duration, signed integer counters), so no custom conversion code is needed.

Schema Definitions

Location: src/schema/*.hpp

Centralized column layouts for traces, logs, and shape-specific metrics. See the Schema Reference for complete column details.

Data Flow

User: SELECT * FROM read_otlp_metrics_gauge('metrics.pb')
  ↓
otlp2records parses OTLP JSON/protobuf into Arrow arrays
  ↓
Arrow bridge copies arrays into DuckDB DataChunks

OTLP HTTP Ingest Server

Alongside the file readers, the extension can run an embedded server that accepts live OpenTelemetry exports and streams them into a DuckDB catalog: the connection’s default in-memory/file catalog, an attached DuckLake lakehouse, or another writable catalog such as an Iceberg REST catalog. The extension registers it as a storage extension, so the database owns running servers and tears them down with it. See the Serve Reference for the SQL API.

The server requires a native build (WASM omits it). Three wire protocols feed the same buffering/seal core: OTLP/HTTP (otlp_serve, the default), OTLP/gRPC unary (otlp_serve(transport := 'grpc')), and OTAP/Arrow bidirectional streaming (otap_serve). The HTTP transport uses httplib; both gRPC families run on an embedded tonic server bridged in via src/otlp_server_grpc.cpp.

A server is one pipeline fed by N listeners, like an OpenTelemetry Collector receiver set: several protocols, one pipeline, one exporter. A listener is a bound socket plus a transport. It owns no buffers or counters; the server owns the buffers, admission cap, writer, and maintenance schedule. The server also decides every ingest outcome: OtlpServer::Admit returns an OtlpIngestOutcome (accepted, or one OtlpIngestRefusal), and a listener only maps it to its own wire status, so a refused payload gets the same answer over HTTP and gRPC. Each catalog target gets at most one server, so HTTP and gRPC traffic for the same catalog seal together, checkpoint on one schedule, and report one readiness state.

The server buffers ingest and commits rows in batches. Worker threads validate, convert, and append rows into an in-memory buffer, then return 202. A single background writer commits the buffer to the target in one transaction. That model keeps the DuckLake path practical: one Parquet data file per signal per batch commit, and one serialized writer that avoids DuckLake optimistic-concurrency retries.

Components

ComponentLocationRole
OtlpServersrc/otlp_server.cpp / src/include/otlp_server.hppThe pipeline: token validation/auth, content-type → format selection, Arrow → DuckDB conversion, the in-memory buffer, the background writer that commits batches into the target catalog, and catalog maintenance. Owns its listeners; starts them after the writer and closes them all before the final drain.
OtlpHttpListenersrc/otlp_server_http.cppOtlpListener wrapping httplib. Owns the worker pool and the /v1/logs, /v1/traces, /v1/metrics, /healthz, and /readyz routes; binds the socket synchronously so callers see bind failures. /readyz reports the shared server’s commit health.
OtlpGrpcListenersrc/otlp_server_grpc.cppOtlpListener wrapping the embedded tonic gRPC server (in otlp2records), bridged into the server via a per-batch C callback that goes through the same OtlpServer::Admit as HTTP. A service_flags arg selects the disjoint service family per listener: OTLP/gRPC unary Export (for otlp_serve(transport := 'grpc')) or OTAP/Arrow streaming (for otap_serve).
OtlpStorageExtensionInfosrc/include/otlp_storage.hppDatabase-scoped registry of running servers (every listener’s scheme-aware listen URI maps to its server; one server per catalog target). Backs CreateServer / FlushServer / StopServer / ListServers, and stops every server when the database closes. It cannot commit buffered rows at that point; see the durability note below.
Lifecycle functionssrc/otlp_start_stop.cppThe otlp_serve, otap_serve, otlp_flush, otlp_stop, otlp_server_list, and otlp_seal_list table functions that drive the registry.

Request flow

Exporter: POST http://localhost:4318/v1/logs  (Bearer token, OTLP body)
  ↓
OtlpHttpListener route → OtlpServer::CheckAuth (Bearer or x-api-key)
  ↓
OtlpServer::Ingest: size, Content-Encoding, Content-Type (json / ndjson / protobuf)
  ↓
OtlpServer::Admit (worker thread): reserve admission bytes -> otlp_transform (FFI) -> convert -> append to per-signal buffer
  ↓
OtlpIngestOutcome: accepted, or a refusal the listener maps to its status (400 / 413 / 415 / 503 / 500)
  ↓
202 {"status":"buffered","rows":N,"batches":M}   (NOT yet durable)

... asynchronously ...

Background writer (trigger: internal size/age threshold; optional otlp_flush)
  → one transaction → for DuckLake: one Parquet data file per signal + one snapshot → COMMIT
  → at most every maintenance_interval_ms, after new commits: best-effort CHECKPOINT <catalog> outside the ingest transaction

Batch commit model and durability

A single background writer commits the buffer to the target catalog when any trigger fires: admitted request-body bytes reach the internal size threshold, 64 MiB today; the oldest buffered row reaches the internal age limit, about 5 seconds today; or a caller runs otlp_flush. Each batch commit is one transaction.

  • A 202 is not durable; rows become durable at the next background commit, on otlp_stop, or on otlp_flush. A crash loses buffered-but-uncommitted rows (at-most-once for that window).
  • otlp_stop and otlp_flush commit remaining buffered rows before returning, so those calls lose no accepted rows. A plain database/connection close does NOT commit buffered rows. The shutdown drain runs after DuckDB tears down the instance, when db_ptr can no longer write, so DuckDB can drop buffered rows. Prefer otlp_stop before closing the database. Use otlp_flush when the server should stay running but readers need durable rows now. The project tracks a durable raw-spool journal and earlier shutdown hook for at-least-once delivery.
  • For a named catalog, the writer runs non-force CHECKPOINT <catalog> as best-effort catalog-native maintenance at most once per maintenance_interval_ms, after rows were committed, outside the ingest transaction. It skips the default catalog; explicit otlp_flush and shutdown drains skip it. The server logs unsupported catalog implementations once and disables maintenance for that server. DuckLake uses this hook to apply its own maintenance policy; duckdb-otlp has no custom compaction planner.

Concurrency model

The server uses a bounded httplib worker pool like duckdb-quack, but sends all target writes through one background thread. The pool parses, converts, and buffers requests concurrently; each signal table has its own buffer lock. Serial writes let a DuckLake target avoid tiny-file churn and optimistic-concurrency retries. Backpressure: if request admission would exceed max_buffered_bytes (default 512 MiB) across in-flight and uncommitted accepted payloads, POSTs return 503 before parse/transform work and clients should retry with backoff.

Key Design Decisions

Schema Design

The table functions emit schemas inspired by the OpenTelemetry ClickHouse exporter, with all column names in snake_case:

  • Traces: 24 columns covering identifiers, scope metadata, resource attributes, events, links, and computed duration
  • Logs: 18 columns with severity, body, resource/scope maps, and trace correlation fields
  • Metrics (gauge): 17 columns with timestamp, service info, metric metadata, and numeric value fields
  • Metrics (sum): 19 columns (gauge columns plus aggregation temporality and is_monotonic)
  • Metrics (histogram): 22 columns with counts, sum, min/max, explicit bounds, and bucket counts
  • Metrics (exponential histogram): 27 columns with scale, zero bucket, and positive/negative bucket data

Streaming Architecture

The extension streams data through DuckDB’s scan interface without loading entire files into memory. This supports:

  • Files larger than available RAM
  • Lower memory use for large datasets
  • Glob pattern scans across many files

File Organization

src/
├── include/           # Public headers (forwarding to implementation dirs)
├── storage/           # Extension entry point registration
├── function/          # Table function implementations (`read_otlp_*`)
├── schema/            # Column layout helpers
├── generated/         # Protobuf message stubs (DO NOT EDIT)
└── wasm/              # WASM build configuration

test/
├── sql/               # SQLLogicTests (primary test format)
└── data/              # Test data (OTLP JSON/protobuf files)

site/
├── book.toml         # mdBook configuration
└── src/              # Pages (SUMMARY.md is the sidebar), install.sh, and the WASM demo

Generated Code

The src/generated/ directory contains protobuf message stubs generated from OpenTelemetry .proto files (*.pb.h, *.pb.cc). These provide the message types consumed by parsers/protobuf_parser.cpp.

Do not edit these files directly. The build excludes them from formatting and linting.

Dependencies

Managed via VCPKG:

  • Protobuf - Wire format parsing for binary OTLP files in builds that include protobuf support

Python dependencies (via uv):

  • black - Python formatting
  • clang-format / clang-tidy - C++ formatting/linting
  • pre-commit - Git hooks

Known Limitations

  • Live ingestion supports OTLP/HTTP, OTLP/gRPC (otlp_serve(transport := 'grpc')), and OTAP/Arrow bidirectional streaming (otap_serve), for all six signals. All transports share one buffering/seal core and the transport-agnostic lifecycle functions (otlp_flush / otlp_stop / otlp_server_list / otlp_seal_list). See Live Ingest Server. Ingest is buffered (an accepted request returns HTTP 202 / gRPC OK) and durable at the next background commit or graceful otlp_stop; a crash loses buffered-but-uncommitted rows (at-most-once). The project tracks a durable raw-spool journal for at-least-once delivery. The server requires a native build (WASM omits it entirely).
  • WASM builds support JSON, JSONL, and protobuf file reads only. Native builds add live ingest.
  • Protobuf parsing requires the protobuf runtime in builds that include protobuf support.
  • Summary metrics are registered placeholders
  • The union metrics function (read_otlp_metrics) is a registered placeholder; use the shape-specific metric readers

Building

See CONTRIBUTING.md for build instructions.

See Also