MongoDB
Etleap can extract data from collections in your MongoDB database.
Source Setup
1. Create a Database User
You can use an existing user that has read access to the database or create a new one by running the following command in the MongoDB shell (mongosh):
use <database>
db.createUser({user: "<username>", pwd: "<password>", roles: ["read"]})
MongoDB Versions Before 3.6.0
To create a MongoDB connection you need to use a MongoDB user that has access to the Oplog. In order to access the Oplog, a database user needs read permissions for the local database. You can create a new user with Oplog access by running the following command in the MongoDB shell (mongosh):
db.createUser({user: "<username>", pwd: "<password>", roles: [{role: "read", db: "local"}]})
2. Whitelist Etleap’s IP Addresses
Etleap’s IP addresses must be whitelisted in MongoDB. There are different addresses to whitelist depending on your deployment model. Review the IP Whitelisting article for more information on which to use.
Prefer using an API? Go here and select MongoDB under the Body header to create your connection via API.
Change Data Capture (CDC) Setup
Etleap extracts data from MongoDB using the database’s Change Stream. For MongoDB versions prior to 3.6.0, where Change Streams are not available, Etleap reads from the Oplog instead.
The Change Stream (or Oplog for older versions) tracks all operations that modify data in your MongoDB database. Therefore no specific setup is required to enable Change Data Capture for MongoDB.
Key Considerations
BSON Datatypes
MongoDB uses BSON (Binary JSON) to store data internally. BSON datatypes that are not supported by standard JSON will be displayed as nested JSON objects and include additional metadata defining the datatype. The table below provides examples of these datatypes and how they are represented in JSON:
Datatype | JSON representation |
---|---|
Long | {"$numberLong": "<long_value>"} |
Date | {"$date": <milliseconds>} |
Timestamp | {"$timestamp": {"t": <pos_integer>, "i": <pos_integer>}} |
Regular Expression | {"$regex": "<pattern>","$options": "<options>"}} |
MinKey | {"$minKey": 1} |
MaxKey | {"$maxKey": 1} |
DBPointer | {"$dbPointer": {"$ref": "<namespace>", "$id": "<object_id>"}} |
Version Compatibility
Etleap supports MongoDB versions 3.4-6.0. Newer versions may be compatible, but have not yet been confirmed.