Skip to main content

Replication PostreSQL to Elasticsearch via Logical replication slots

Project description

Replication PostreSQL to Elasticsearch via Logical replication slots


$ pip install pg-replicate-elastic


Note: Use my fork as we tested it to be 100% sure it work with it and no breaking changes happen, wal2json .

$ git clone
$ PATH=/path/to/bin/pg_config:$PATH
$ USE_PGXS=1 make
$ USE_PGXS=1 make install

You need to set up at least two parameters at postgresql.conf:

wal_level = logical
max_replication_slots = 1

After changing these parameters, a restart is needed.


pg_replicate_elastic --config=<absolute path to json config>

Construct configuration file in json format where:

  • replication_slot json object for replication slot name and if is temporary
  • tables is array of tables we want to replicate
  • es_connection connection string to Elasticsearch
  • postgres json object for PostreSQL connection
  • inital_sync boolean for inital syncronization that needs to be done first time to replicate old data

Example configuration

	"replication_slot": {
		"name": "elasticsearch_slot",
		"is_temp": true
	"tables": [{
		"name": "poc",
		"primary_key": "a"
		"exclude_columns": "c,z"
	"es_connection": "",
	"postgres": {
		"port": 5432,
		"host": "",
		"database": "poc",
		"username": "test",
		"password": "test"
	"inital_sync": false


wal2json is not my software so for licence check their licence

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pg-replicate-elastic, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size pg_replicate_elastic-1.0.3-py2-none-any.whl (5.6 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size pg-replicate-elastic-1.0.3.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page