Skip to main content

Send OpenTelemetry to Apache Iceberg tables

Export OTLP directly from your SDKs or an existing Collector. Send2Bucket appends logs, spans and metrics to an Iceberg table through your REST catalog. Each batch creates one snapshot, with a commit at least once a minute while data flows.

The table​

Send2Bucket creates the table at setup, if it is missing, with four columns:

ColumnTypeValue
signal_typestringlog, span, metric, or event for JSON events
delivery_batch_idstringThe delivery batch whose snapshot added the row
ingested_attimestamptzWhen Send2Bucket accepted the record
payloadstringThe record's envelope as JSON: resource, scope and the OTLP data

Telemetry changes shape with every new attribute, so the columns stay fixed and the record stays JSON. Typed views, shown below, give your queries real columns. Delivery format describes the envelope.

1. Create the destination​

  1. Create a namespace in your catalog, for example otel.
  2. In the dashboard, create an ingestion stream and add an Apache Iceberg destination: catalog URI, warehouse, namespace, table, a catalog token, and an S3 key that can write the table's data files.
  3. Select Verify. Send2Bucket creates the table, or reuses a compatible one.

Apache Iceberg lists every field and the access each credential needs. For AWS-managed tables use OpenTelemetry to Amazon S3 Tables; for a Supabase project use Supabase Analytics Buckets.

2. Partition by day before the first delivery​

Send2Bucket writes with the table's partition spec. Add a day partition on ingested_at after setup and before you send data, so queries that filter on time skip old files. With PyIceberg:

from pyiceberg.catalog import load_catalog
from pyiceberg.transforms import DayTransform

catalog = load_catalog(
"s2b",
type="rest",
uri="<catalog_uri>",
warehouse="<warehouse>",
token="<catalog_token>",
)
table = catalog.load_table("otel.telemetry")
with table.update_spec() as spec:
spec.add_field("ingested_at", DayTransform(), "ingested_day")
print(table.spec())
[
1000: ingested_day: day(3)
]

Data files then land under ingested_day=<n>/ in the table's location. In Spark with the Iceberg SQL extensions, ALTER TABLE … ADD PARTITION FIELD days(ingested_at) does the same.

3. Point your exporters at Send2Bucket​

Set the standard OpenTelemetry variables with the stream's API key:

export OTEL_SERVICE_NAME=checkout
export OTEL_EXPORTER_OTLP_ENDPOINT=https://api.send2bucket.com
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer%20$S2B_API_KEY"

A Collector forwards with an otlphttp exporter instead; the S3 guide has the configuration. JSON events sent to /v1/events on the same stream land in the same table with signal_type = 'event'.

4. Query with typed views​

DuckDB attaches the catalog. These views turn spans and logs into columns:

INSTALL httpfs; LOAD httpfs; INSTALL iceberg; LOAD iceberg;
CREATE SECRET s2b_storage (TYPE s3, KEY_ID '<access_key_id>', SECRET '<secret_access_key>', REGION '<region>');
CREATE SECRET s2b_catalog (TYPE iceberg, TOKEN '<catalog_token>');
ATTACH '<warehouse>' AS lakehouse (TYPE iceberg, ENDPOINT '<catalog_uri>', SECRET s2b_catalog);

CREATE VIEW spans AS
SELECT ingested_at,
(SELECT a->>'$.value.stringValue'
FROM unnest(json_extract(p->'$.resource', '$.attributes[*]')) AS t(a)
WHERE a->>'$.key' = 'service.name') AS service,
p->>'$.data.traceId' AS trace_id,
p->>'$.data.spanId' AS span_id,
p->>'$.data.parentSpanId' AS parent_span_id,
p->>'$.data.name' AS name,
make_timestamp_ns((p->>'$.data.startTimeUnixNano')::BIGINT) AS started_at,
((p->>'$.data.endTimeUnixNano')::HUGEINT - (p->>'$.data.startTimeUnixNano')::HUGEINT) / 1e6 AS duration_ms,
coalesce((p->>'$.data.status.code')::INTEGER, 0) AS status_code,
p->'$.data.attributes' AS attributes
FROM (SELECT ingested_at, payload::JSON AS p FROM lakehouse.otel.telemetry WHERE signal_type = 'span');

CREATE VIEW logs AS
SELECT ingested_at,
(SELECT a->>'$.value.stringValue'
FROM unnest(json_extract(p->'$.resource', '$.attributes[*]')) AS t(a)
WHERE a->>'$.key' = 'service.name') AS service,
make_timestamp_ns((p->>'$.data.timeUnixNano')::BIGINT) AS logged_at,
p->>'$.data.severityText' AS severity,
p->>'$.data.body.stringValue' AS body,
p->>'$.data.traceId' AS trace_id
FROM (SELECT ingested_at, payload::JSON AS p FROM lakehouse.otel.telemetry WHERE signal_type = 'log');

Latency and errors per operation over the last day. With the day partition, engines that prune Iceberg partitions, such as Trino and Spark, skip older days for this filter:

SELECT service, name, count(*) AS spans,
round(quantile_cont(duration_ms, 0.95), 1) AS p95_ms,
count(*) FILTER (WHERE status_code = 2) AS errors
FROM spans
WHERE ingested_at >= now() - INTERVAL 1 DAY
GROUP BY ALL
ORDER BY p95_ms DESC;

Error logs next to the failing span of the same trace:

SELECT l.service, l.severity, l.body, s.name AS span
FROM logs l JOIN spans s USING (trace_id)
WHERE l.severity = 'ERROR' AND s.status_code = 2;
┌───────────┬──────────┬───────────────┬─────────────┐
│ service │ severity │ body │ span │
├───────────┼──────────┼───────────────┼─────────────┤
│ checkout │ ERROR │ card declined │ charge card │
│ inventory │ ERROR │ card declined │ charge card │
└───────────┴──────────┴───────────────┴─────────────┘

Each delivery batch is a snapshot, so the snapshot list doubles as a delivery log:

SELECT snapshot_id, timestamp_ms
FROM iceberg_snapshots(lakehouse.otel.telemetry)
ORDER BY timestamp_ms DESC
LIMIT 5;

The same table reads from Trino, Apache Spark, Snowflake, ClickHouse and the other engines under Querying. Give readers their own read-only catalog token and storage key. To set up Trino against the catalog step by step, see Connect Trino to an Iceberg REST catalog.

Table maintenance​

One snapshot per batch means about 1,440 snapshots and at least as many small data files per day on a busy stream. Iceberg readers slow down as both grow, so schedule maintenance with an engine that has write access:

  • Compact small files, for example daily, with Spark's rewrite_data_files procedure.
  • Expire snapshots older than the time travel you need with expire_snapshots, then remove orphan files.

Some managed catalogs run both for you; check yours. If a compaction commit and a Send2Bucket append conflict, the append fails and is retried; before each retry Send2Bucket looks for the batch's delivery_batch_id, so a batch is never added twice. See Delivery and retries.

Limits and costs​

  • A request can be up to 8 MiB decompressed; a single log record, span or metric has no separate limit.
  • Send2Bucket bills the stored JSON of each log record, span or metric it accepts (Plans and billing). Your storage provider bills the Parquet data files, and your catalog provider any catalog charges.
  • Send2Bucket does not sample or drop records. Sample in the SDK or Collector.