anuj_lathi
Databricks Employee
Databricks Employee

Yes, that pattern works, and Zerobus isn't needed for it. Put Kafka between OTel and Lakebase as the buffer, then have a consumer write into Lakebase over its Postgres endpoint. Nothing needs to land in Delta first.

I'm assuming LTAP means the Lakebase-to-lakehouse analytics path. If you mean something else, tell me and I'll adjust.

Recommended flow

  1. OTel Collector → Kafka. The collector's Kafka exporter is fire-and-forget from the app's point of view, and Kafka absorbs bursts and gives you replay.
  2. Kafka → Lakebase. You have two options:
    • A Databricks streaming job. Structured Streaming or a Lakeflow pipeline with the Kafka source [1] gives you checkpointing and managed retries. Use foreachBatch to write each micro-batch to Lakebase over Postgres.
    • A consumer outside Databricks. A Kafka Connect JDBC sink or a small service that writes straight to the Lakebase Postgres endpoint. Pick this if you don't want a Databricks cluster running just to move data.
  3. Lakebase → analytics. Use whatever Lakebase-to-lakehouse path your LTAP plans rely on, downstream of this.

Sketch of the foreachBatch option

def write_to_lakebase(batch_df, batch_id):
    # 1. Bulk-write the micro-batch into a staging table in Lakebase (JDBC/Postgres)
    (batch_df.write
        .format("jdbc")
        .option("url", jdbc_url)              # Lakebase Postgres endpoint
        .option("dbtable", "staging.otel_events")
        .option("user", user)
        .option("password", oauth_token)      # short-lived token, refresh it
        .mode("overwrite")
        .save())
    # 2. Merge into the target idempotently, e.g. via psycopg:
    #    INSERT INTO otel_events SELECT * FROM staging.otel_events
    #    ON CONFLICT (event_id) DO NOTHING;

(spark.readStream
    .format("kafka")
    .option("kafka.bootstrap.servers", brokers)
    .option("subscribe", "otel-events")
    .load()
    # parse / flatten OTel payload here
    .writeStream
    .foreachBatch(write_to_lakebase)
    .option("checkpointLocation", checkpoint_path)
    .start())

Things that matter in practice

  • Make writes idempotent. Kafka to Postgres is at-least-once, because a batch can be replayed after a failure. Give each event a stable key and use INSERT ... ON CONFLICT DO NOTHING (or DO UPDATE) so replays are harmless.
  • Batch your writes. Use micro-batches with a staging table or COPY, not row-at-a-time inserts. That's the biggest throughput lever on the Postgres side.
  • Handle credentials. Lakebase connections use short-lived OAuth tokens, so make sure long-running writers refresh them rather than caching one for the life of the job.
  • Size for telemetry volume. Raw OTel traces and logs can be very high-volume and append-heavy, which Postgres handles less cheaply than Delta. Land in Lakebase only what needs low-latency or transactional access, such as recent state, aggregates, or lookups. Keep the full-fidelity firehose in Delta via the Kafka ingestion path [1].

If you share your expected events per second and what the app reads from Lakebase, I can suggest whether to use the in-Databricks streaming writer or an external sink.

References

[1] Ingest with SQL and Spark APIs | Databricks on AWS — https://docs.databricks.com/aws/en/ingestion

Anuj Lathi
Solutions Engineer @ Databricks