Skip to content

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.

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.

In another terminal:

Terminal window
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:

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

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 │
└─────────────────────┴──────────────┴───────────────┴─────────────────┘