Connect data

Streaming subscriptions

Kafka and Google Pub/Sub streaming subscriptions in Goni: subscription CRUD, lag, DLQ browser, schema registry integration.

Streaming subscriptions

Continuously land Kafka topics and Google Pub/Sub subscriptions into your ClickHouse warehouse through Goni’s streaming plane, then query the results next to your batch pipelines.

Beta: Kafka and Pub/Sub subscriptions are in beta, so subscription creation is gated by an operator opt-in (see below).

You will learn:

  • The subscription lifecycle: create, pause, resume, reset offset, delete
  • How the raw and DLQ landing zones are shaped in ClickHouse
  • How to inspect lag, browse the DLQ, redrive poison-pill events
  • Where Confluent Schema Registry and Pub/Sub Schema Service plug in
  • The per-workspace subscription cap and current limitations

Enable streaming on the deployment

Goni refuses subscription creation up front until an operator flips the gate. This keeps a fresh install from silently persisting rows for subscriptions the streaming plane cannot yet serve.

# On your Goni deployment
GONI_STREAMING_ENABLED=1

Without this flag the streaming plane is off: POST /api/streaming/subscriptions and the pause, resume, reset-offset, delete, status and DLQ redrive endpoints return 503 with {"code": "streaming_disabled"}, Kafka and Pub/Sub show as unavailable in the connector catalog and cannot be created, an existing Kafka or Pub/Sub pipeline is not run (one run records STREAMING_DISABLED so you can see why), and the background orphan sweeper does not run. Set the flag only on a deployment where stream-hub is running.

The per-workspace cap defaults to 50 subscriptions:

GONI_MAX_STREAMING_SUBS_PER_TENANT=50   # 0 or negative = uncapped

Every subscription reserves up to 100 MiB of buffer memory, so the cap is enforced admission-time. Hitting it returns 429 Too Many Requests.

Connect a broker first

Before you can create a subscription, register a connection of kind kafka or pubsub on the Connectors page. The subscription references that connection by id; the create call refuses mismatched kinds and cross-workspace references.

Create a subscription

Go to the Streaming page and click “New subscription”, or POST directly:

curl -X POST https://your-goni-host/api/streaming/subscriptions \
  -H "Content-Type: application/json" \
  -d '{
    "id": "orders-live",
    "name": "Orders live",
    "connection_id": "kafka-prod",
    "kind": "kafka",
    "target_pipeline": "orders_events",
    "ack_semantics": "at-least-once",
    "topics": ["orders.v1"],
    "consumer_group_id": "goni-orders-live",
    "offset_reset_policy": "earliest"
  }'

For Pub/Sub, send kind: "pubsub" and a subscription_id referring to the Pub/Sub subscription; leave topics and consumer_group_id empty.

id and consumer_group_id must match ^[a-z0-9][a-z0-9_-]{0,62}$.

The create path:

  1. Persists the subscription row in the control plane.
  2. Runs the streaming landing-zone DDL against the warehouse (idempotent).
  3. Dispatches an ensure call to the streaming plane over Arrow Flight. Dispatch failure returns 202 with the row; the scheduler re-nudges on the next tick.

Lifecycle

MethodPathPermissionWhat it does
GET/api/streaming/subscriptionsUserList the workspace’s subscriptions
POST/api/streaming/subscriptionsAllowSaveCreate
POST/api/streaming/subscriptions/{id}/pauseAllowSaveStamp paused_at, tell the streaming plane to stop fetching
POST/api/streaming/subscriptions/{id}/resumeAllowSaveClear paused_at, tell the streaming plane to resume fetching
POST/api/streaming/subscriptions/{id}/reset-offsetAllowSaveReset the consumer offset (Kafka only, Pub/Sub returns “unsupported”). Request body below.
DELETE/api/streaming/subscriptions/{id}AllowDeleteStops the subscription, drops the landing tables, deletes the row

Reset-offset request body:

{
  "policy": "earliest",
  "timestamp_ms": 1723449600000
}

policy accepts earliest, latest, or timestamp. timestamp_ms is required only when policy is timestamp.

Pause and resume are best-effort against the streaming plane: the control-plane write is the source of truth. Delete is not best-effort - if the streaming plane cannot confirm the subscription is stopped, Goni refuses the drop and returns 502 so the landing tables never get dropped under a still-consuming subscription.

Live status and lag

Each row in the Streaming page renders a live lag pill polling a status endpoint. The pill shows the current consumer lag (Kafka) or unacked backlog (Pub/Sub) and a rolling sparkline of the last window.

Backpressure signals come from the streaming plane’s memory limiter. When the ClickHouse sink cannot keep up, consumption pauses until it drains - the lag pill on affected subscriptions turns amber.

Landing zones

Every subscription lands into a per-pipeline table triple in the warehouse, created idempotently by the streaming plane:

TableEnginePARTITION BYORDER BY
raw_events_<pipeline>ReplacingMergeTree(_goni_version)toYYYYMM(_goni_ingested_at)(message_id)
dlq_events_<pipeline>ReplacingMergeTreetoYYYYMM(dlq_ingested_at)(message_id, error_class)
raw_events_<pipeline>__goni_currentVIEW (argMax on _goni_version)--

_goni_version is a monotonic per-subscription counter so the highest version wins on replay. _goni_ingested_at is stamped by the streaming plane at receipt time. The __goni_current view is what your semantic-layer marts should read from - it collapses duplicates without paying FINAL. See Sources and models for how to reference these tables.

DLQ browser

Poison-pill messages (schema decode failure, envelope corruption, oversize) land in dlq_events_<pipeline>. Click a subscription on the Streaming page to open the DLQ drawer.

The drawer supports:

  • Facet by error_class (GET /api/streaming/subscriptions/{id}/dlq/error-classes).
  • Free-text search across message_id / partition_key / error_message (debounced).
  • Preset time ranges: last hour, 24 hours, 7 days, custom, or all.
  • Per-row Redrive - POSTs /dlq/{event_id}/redrive, which republishes to the source topic (Kafka producer or Pub/Sub publish).
  • Per-row Resolve - POSTs /dlq/{event_id}/resolve, marking the row resolved so it stops appearing in the default view without deleting the audit trail.
  • Expand a row to fetch the raw payload (GET /dlq/{event_id}/raw) as base64 bytes; useful for offline decode.
  • Toggle “show resolved” and “show redriven” - both default off.

Schema registry integration

Kafka and Pub/Sub each ship their own registry decoder:

  • Confluent Schema Registry - decodes the Confluent envelope [magic:1][schema_id:4:BE][payload:N]. Avro payloads are decoded to native types; Protobuf strips the message-index varints and passes bytes through (dynamic descriptor decode is not supported); bare JSON is parsed directly. A subject can be pinned to a specific version so a producer accidentally registering an incompatible schema does not break the consumer.
  • Pub/Sub Schema Service - fetches the schema attached to the subscription’s topic and caches it. Supports JSON, Avro, and Protobuf encodings.

On the subscription form, set schema_registry.url (Kafka) or leave the Pub/Sub side unset - the topic’s attached schema is discovered automatically.

The on_schema_change knob picks the drift policy per subscription: propagate (default), ignore, or pause. Empty on the wire maps to propagate.

Current limitations

  • Exactly-once Kafka semantics. The current Kafka path composes an effectively-once contract from read_committed isolation, commit-after-write, per-batch insert_deduplication_token, and ReplacingMergeTree dedup. Setting ack_semantics: "exactly-once" on a Kafka subscription is accepted, but the guarantee is effectively-once, not broker-side exactly-once.
  • Pub/Sub exactly-once requires the parent connection’s enable_exactly_once_delivery=true. Without it, the create call returns 400.

Last updated