Getting Started¶
Requirements¶
- Postgres 15+ with
wal_level=logical - User with
REPLICATIONprivilege
Check your setting:
Enable if needed (requires restart):
Configure¶
Create config.yaml:
stream:
id: 1
pg_connection:
host: localhost
port: 5432
name: mydb
username: postgres
password: postgres
tls:
enabled: false
batch:
max_size: 1000
max_fill_secs: 5
sink:
type: webhook
url: https://httpbin.org/post
Run¶
Each sink has its own image: kafka-latest, nats-latest, sqs-latest, etc.
Install the Optional Subscription Package¶
Subscriptions are user-managed SQL and are not installed by the pgstream daemon. Copy the provided migration into your application's migration system and run it as the role that owns your subscribed tables:
psql "$DATABASE_URL" \
--set ON_ERROR_STOP=1 \
--single-transaction \
--file extensions/subscriptions/migrations/0001_create_pgstream_subscriptions.sql
See Subscription Setup for ownership, grants, and customization.
Create a Subscription¶
INSERT INTO pgstream_subscriptions.subscriptions (
key, stream_id, operation, schema_name, table_name, column_names
)
VALUES (
'user-created', 1, 'INSERT', 'public', 'users', array['id', 'email']
);
Now inserts into users are streamed to your webhook.
Next Steps¶
- Subscription Setup - Install the optional SQL package
- Subscriptions - Filter events, select columns
- Sinks - Configure your destination
- Configuration Reference - All options