Skip to main content

Mongo DB

The MongoDB source allows to sync data from MongoDb. Source supports Full Refresh and Incremental sync strategies.

Resulting schema

MongoDB does not have anything like table definition, thus we have to define column types from actual attributes and their values. Discover phase have two steps:

Step 1. Find all unique properties

Connector select 10k documents to collect all distinct field.

Step 2. Determine property types

For each property found, connector determines its type, if all the selected values have the same type - connector will set appropriate type to the property. In all other cases connector will fallback to string type.

Features

FeatureSupported
Full Refresh SyncYes
Incremental - Append SyncYes
Replicate Incremental DeletesNo
NamespacesNo

Full Refresh sync

Works as usual full refresh sync.

Incremental sync

Cursor field can not be nested. Currently only top level document properties are supported.

Cursor should never be blank. In case cursor is blank - the incremental sync results might be unpredictable and will totally rely on MongoDB comparison algorithm.

Only datetime and number cursor types are supported. Cursor type is determined based on the cursor field name:

  • datetime - if cursor field name contains a string from: time, date, _at, timestamp, ts
  • number - otherwise

Getting started

This guide describes in details how you can configure MongoDB for integration with Airbyte.

Create users

Run mongo shell, switch to admin database and create a READ_ONLY_USER. READ_ONLY_USER will be used for Airbyte integration. Please make sure that user has read-only privileges.

mongo
use admin;
db.createUser({user: "READ_ONLY_USER", pwd: "READ_ONLY_PASSWORD", roles: [{role: "read", db: "TARGET_DATABASE"}]})

Make sure the user have appropriate access levels, a user with higher access levels may throw an exception.

Enable MongoDB authentication

Open /etc/mongod.conf and add/replace specific keys:

net:
bindIp: 0.0.0.0

security:
authorization: enabled

Binding to 0.0.0.0 will allow to connect to database from any IP address.

The last line will enable MongoDB security. Now only authenticated users will be able to access the database.

Configure firewall

Make sure that MongoDB is accessible from external servers. Specific commands will depend on the firewall you are using (UFW/iptables/AWS/etc). Please refer to appropriate documentation.

Your READ_ONLY_USER should now be ready for use with Airbyte.

TLS/SSL on a Connection

It is recommended to use encrypted connection. Connection with TLS/SSL security protocol for MongoDb Atlas Cluster and Replica Set instances is enabled by default. To enable TSL/SSL connection with Standalone MongoDb instance, please refer to MongoDb Documentation.

Сonfiguration Parameters

  • Database: database name
  • Authentication Source: specifies the database that the supplied credentials should be validated against. Defaults to admin.
  • User: username to use when connecting
  • Password: used to authenticate the user
  • Standalone MongoDb instance
    • Host: URL of the database
    • Port: Port to use for connecting to the database
    • TLS: indicates whether to create encrypted connection
  • Replica Set
    • Server addresses: the members of a replica set
    • Replica Set: A replica set name
  • MongoDb Atlas Cluster
    • Cluster URL: URL of a cluster to connect to

For more information regarding configuration parameters, please see MongoDb Documentation.

Changelog

VersionDatePull RequestSubject
0.2.12023-07-2128527Log server information
0.2.02023-06-2627737License Update: Elv2
0.1.192022-10-0717614Increased discover performance
0.1.182022-10-0517590Add ability to enforce SSL in MongoDB connector and check logic
0.1.172022-09-0816401Fixed bug with empty strings in fields with aibyte_transform
0.1.162022-08-1814356DB Sources: only show a table can sync incrementally if at least one column can be used as a cursor field
0.1.152022-06-1713864Updated stacktrace format for any trace message errors
0.1.142022-05-0512428JsonSchema: Add properties to fields with type 'object'
0.1.132022-02-2110276Create a custom codec registry to handle DBRef MongoDB objects
0.1.122022-02-1410256(unpublished) Add -XX:+ExitOnOutOfMemoryError JVM option
0.1.112022-01-109238Return only those collections for which the user has privileges
0.1.102021-12-309202Update connector fields title/description
0.1.92021-12-078491Configure 10000 limit doc reading during Discovery step
0.1.82021-11-298306Added milliseconds for date format for cursor
0.1.72021-11-228161Updated Performance and updated cursor for timestamp type
0.1.52021-11-178046Added milliseconds to convert timestamp to datetime format
0.1.42021-11-157982Updated Performance
0.1.32021-10-197160Fixed nested document parsing
0.1.22021-10-076860Added filter to avoid MongoDb system collections
0.1.12021-09-216364Source MongoDb: added support via TLS/SSL
0.1.02021-08-305530New source: MongoDb ported to java