After you select Generic MongoDB as the Source for creating the Pipeline, provide the connection settings and data replication details on the Configure your MongoDB Source page.
You can connect to the MongoDB database in one of the following ways:
-
By specifying the individual connection fields such as database host, database port, username, and password.
-
By entering the connection URI to connect to your MongoDB replica set or sharded cluster.
Connection URIs are of two types:
-
DNS Seedlist: This type of connection URI has the prefix mongodb+srv://
.
For example, mongodb+srv://<Jerome>:<Hevo123>@demo.westeros.net/
.
The +srv
part indicates that the hostname corresponds to a DNS SRV record. The hostnames and port values for your MongoDB database are fetched from the DNS SRV record.
-
Standard Connection String: This type of connection URI has the prefix mongodb://
. This contains a comma-separated list of host:port combinations.
For example, mongodb://Jerome:Hevo123@demo1.westeros.net:21275,demo2.westeros.net:21275/
.
In the above example, Jerome
is the database user, Hevo123
is the password for the database user, demo1.westeros.net
is the IP address or hostname of the database, and 21275
is the database port.
Prerequisites
Perform the following steps to configure your Generic MongoDB Source:
Set up MongoDB Replication for OpLog and Change Streams
Note: Hevo supports data ingestion from MongoDB via OpLog and Change Streams. Change Streams internally use OpLog for replication.
To set up replication for OpLog or Change Streams, perform the following steps:
-
Modify the MongoDB server configuration: MongoDB configuration file, mongod.conf
, is generally found in /etc/
directory in a Linux system. The options to configure are as follow.
-
replication.replSetName: The replica set this MongoDB is part of.
-
replication.oplogSizeMB: The maximum size of the log that MongoDB will retain. We recommend setting it to 2048 MB (2 GB) to maintain adequate capacity.
-
net.bindIp: The IP this MongoDB server should listen to.
An example config will look like as follows:
net:
bindIp: 0.0.0.0
replication:
replSetName: "repSet0"
oplogSizeMB: 2048
-
Configure replication through MongoDB shell: Open your Mongo shell on the replication server and run the following commands:
-
rs.initiate(): This command will initialize the replica set.
-
rs.conf(): This command will show you the replication configuration that has been set.
-
rs.status(): This command will show you the replication status.
Set up Permissions to Read Generic MongoDB Databases
After you set up replication for OpLog and Change Streams, you must assign read
privilege to the database user to read from the local
database and the databases to be replicated. To do this:
-
Open the MongoDB shell.
-
Connect to your replica set or sharded cluster as an admin
user.
-
Run the following commands to create a user and assign it permissions:
use admin
db.createUser({
user: "<username>",
pwd: "<password>",
roles: [ "readAnyDatabase", {role: "read", db: "local"} ]
})
Note: Replace the placeholder values in the command above with your own. For example, <username> with hevouser.
Whitelist Hevo’s IP Addresses
In order to allow Hevo to access your MongoDB databases, you must whitelist Hevo’s IP addresses.
To do this, add the IP addresses to the list of authenticated IP Addresses/CIDR of your MongoDB instance by following these simple steps.
Perform the following steps to configure Generic MongoDB as a Source in Hevo:
-
Click PIPELINES in the Navigation Bar.
-
Click + CREATE PIPELINE in the Pipelines List View.
-
On the Select Source Type page, select MongoDB.
-
On the Configure your MongoDB Source page, specify the following:
-
Pipeline Name: A unique name for the Pipeline, not exceeding 255 characters.
-
General Connection Settings:
-
Authentication Database Name: The database that stores the user’s information. The user name and password entered in the preceding steps are validated against this database. Default: admin.
-
Connect through SSH: Enable this option to connect to Hevo using an SSH tunnel, instead of directly connecting your MongoDB database host to Hevo. This provides an additional level of security to your MongoDB database by not exposing your MongoDB setup to the public. Read Connecting Through SSH.
If this option is disabled, you must whitelist Hevo’s IP addresses to allow Hevo to connect to your MongoDB host.
-
Use SSL: Enable this toggle option if you have enabled SSL at the MongoDB server end.
Note: You must enable this option if the Connection URI or Database Host field contains the hostname of a sharded cluster.
-
Select an Ingestion Mode: The desired mode by which you want to ingest data from the Source. You can expand this section by clicking SEE MORE to view the list of ingestion modes to choose from. Default value: OpLog.
The following ingestion modes are applicable to MongoDB Source:
-
OpLog: Data is ingested using MongoDB’s OpLog. The OpLog contains individual, transaction-level details which helps replicas sync data from the primary instance.
Note: OpLogs are present in data or standalone primary instances and replicas.
-
Change Streams: MongoDB’s Change Streams enables applications to stream real-time data changes without the complexity and risk of tailing the OpLog, for a single collection, a database, or an entire deployment. Change Streams are supported for all MongoDB configurations. However, for the clustered configuration, Change Streams works only if set up against a shard router (mongos).
By default, in both Change Streams and OpLog mode, the data is read at the mongo instance level. To read data at the database level in Change Streams mode, disable the Load All Databases option while creating the Pipeline.
-
Advanced Settings:
-
Load All Databases: If enabled, Hevo fetches data from all the databases you have access to on the specified database host(s).
If disabled, Hevo fetches the list of all the databases you have access to on the specified database host(s). From this list, you must select the databases you want to fetch data from.
Warning! Once the Pipeline is created, if you drop any of these databases from your MongoDB Source, the Pipeline will fail.
-
Merge Collections: If enabled, collections with the same name across different databases are merged into a single Destination table. If disabled, separate tables are created and prefixed with the respective database name. Read Example - Merge Collections Feature.
-
Load Historical Data: If disabled, Hevo loads only the data that was written in your database after the time of the creation of the Pipeline. If enabled, the entire table data is fetched during the first run of the Pipeline.
-
Include New Tables in the Pipeline: If enabled, Hevo automatically ingests data from tables created after the Pipeline has been built. If disabled, the new tables are listed in the Pipeline Detailed View in Skipped state, and you can manually include the ones you want and load their historical data.
You can change this setting later.
-
Click TEST CONNECTION. This button is enabled once you specify all the mandatory fields. Hevo’s underlying connectivity checker validates the connection settings you provide.
-
Click TEST & CONTINUE to proceed for setting up the Destination. This button is enabled once you specify all the mandatory fields.
Data Replication
For Teams Created |
Default Ingestion Frequency |
Minimum Ingestion Frequency |
Maximum Ingestion Frequency |
Custom Frequency Range (in Hrs) |
Before Release 2.21 |
5 Mins |
5 Mins |
1 Hr |
NA |
After Release 2.21 |
30 Mins |
30 Mins |
12 Hrs |
1-24 |
Note: The custom frequency must be set in hours as an integer value. For example, 1, 2, or 3 but not 1.5 or 1.75.
-
Historical Data: In the first run of the Pipeline, Hevo ingests all available data for the selected objects from your Source database.
-
Incremental Data: Once the historical load is complete, data is ingested as per the ingestion frequency.
Read the detailed Hevo documentation for the following related topics:
Error 1001 - Incorrect credentials
Potential Causes
- The credentials of the database user authorizing the connection are incorrect.
Suggested Actions
-
Verify that the password entered in the Configure your Source page for the authorizing user is correct.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1005 - Connection timeout
Potential Causes
- The database connection details are incorrect.
- Hevo’s IP addresses are not whitelisted.
Suggested Actions
-
Verify that the hostname entered in the Configure your Source page is correct.
-
Verify that the port entered in the Configure your Source page is correct.
-
Verify that Hevo’s IP addresses for your region are whitelisted. Refer to the Source configuration document for more information.
-
For MongoDB Atlas, refer to the detailed setup guide.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1006 - Invalid database hostname
Potential Causes
- The database hostname is incorrect.
Suggested Actions
-
Verify that the hostname entered in the Configure your Source page is correct.
-
Use the Connection String mode to enter the details if a connection string is used to setup the MongoDB Source.
-
Use the Connect via SSH option to set up the Source if the MongoDB instance is on a local IP address.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1007 - SSH connection failed
Potential Causes
- The SSH host or user credentials are incorrect.
Suggested Actions
-
Verify that the SSH IP address entered in the Configure your Source page is correct.
-
Verify that the SSH Port entered in the Configure your Source page is correct.
-
Verify that the SSH user and password entered are correct.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1008 - Database unreachable
Potential Causes
- Hevo’s IP addresses are not whitelisted.
- Hevo is unable to connect to the database.
Suggested Actions
-
Verify that the port entered in the Configure your Source page is correct.
-
Verify that Hevo’s IP addresses for your region are whitelisted. Refer to the Source setup page for more information.
-
For MongoDB Atlas, refer to the detailed setup guide.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1011 - Insufficient access
Potential Causes
- The configured database user does not have the correct permissions.
Suggested Actions
-
To set permissions for the user, follow the steps mentioned in the setup guides below:
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1028 - Primary/Master host needed for OpLog
Potential Causes
- The Database Host specified is that of a shard or a replica set. The primary/master host must be mentioned while setting up the connection.
Suggested Actions
-
Verify that the hostname entered in the Configure your Source page has the primary/master hostname.
-
If MongoDB version 4.0 or above is used, select Change Streams as the Pipeline mode.
-
Invite another team member with the required privileges to set up the Pipeline. Read Inviting and Moderating Team Members.
Error 1029 - Version not supported for Change Streams
Potential Causes
- The MongoDB version is lower than 4.0. Change Streams-based replication is only supported on MongoDB version 4.0 and above.
Suggested Actions
Limitations
- Hevo does not support configuring a standalone instance of MongoDB without a replica.
See Also
Revision History
Refer to the following table for the list of key updates made to this page:
Date |
Release |
Description of Change |
Nov-05-2024 |
NA |
Updated section, Configure Generic MongoDB Connection Settings as per the latest Hevo UI. |
Oct-09-2024 |
NA |
Updated sections, Prerequisites and Set up Permissions to Read Generic MongoDB Databases to reflect that Hevo only supports MongoDB version 3.4 and higher. |
Apr-29-2024 |
NA |
Updated section, Configure Generic MongoDB Connection Settings to include more detailed steps. |
Mar-05-2024 |
2.21 |
Added the Data Replication section. |
Feb-02-2024 |
NA |
Updated section, Configure Generic MongoDB Connection Settings to add information about sharded clusters. |
Mar-16-2023 |
NA |
Added a warning in the Advance Settings in section, Configure Generic MongoDB Connection Settings about dropping databases from the Source after the Pipeline is created. |
Mar-09-2023 |
2.09 |
Updated section, Configure Generic MongoDB Connection Settings to mention about SEE MORE in the Select an Ingestion Mode section. |
Dec-19-2022 |
2.04 |
Updated section, Configure Generic MongoDB Connection Settings to add information that you must specify all fields to create a Pipeline. |
Dec-07-2022 |
2.03 |
Updated section, Configure Generic MongoDB Connection Settings to mention about the connectivity checker. |
Jul-12-2022 |
1.92 |
Updated section, Configure Generic MongoDB Connection Settings to include information about the drop-down to select databases in the Load All Databases option. |
Apr-21-2022 |
1.86 |
Updated section, Configure Generic MongoDB Connection Settings. |
Jul-12-2021 |
1.67 |
Added the field Include New Tables in the Pipeline under Source configuration settings. |
Jun-28-2021 |
1.66 |
- Updated the page overview section. - Updated the section Set up Permissions to Read Generic MongoDB Databases to include latest commands. - Updated the section Configure Generic MongoDB Connection Settings to include the option to connect to the MongoDB database using connection string. - Added section, Limitations. |