Generic MongoDB

After you select Generic MongoDB as the Source for creating the Pipeline, provide the connection settings and data replication details in 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>

      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://,

      In the above example, Jerome is the database user, Hevo123 is the password for the database user, is the IP address or hostname of the database, and 21275 is the database port.


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:

  1. 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 max size of logs that mongo will persist keep this enough high we recommend 2048 MB (2GB).

    • net.bindIp: The IP this MongoDB server should listen to.

      An example config will look like as follows:

       replSetName: "repSet0"  
       oplogSizeMB: 2048
  2. 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:

  1. Open the MongoDB shell.

  2. Connect to your replica set or sharded cluster as an admin user.

  3. Depending on the MongoDB version, run the following commands to create a user and assign it permissions.

    • For MongoDB versions between 2.4 and 2.6:

       use admin
       { user: "<username>",
       pwd: "<password>",
       roles: ["readAnyDatabase"]
       Replace <username> and <password> with a username and password of your choice.
    • For MongoDB versions between 3.0 and 3.2:

       use admin
       user: "<username>",
       pwd: "<password>",
       roles: [ "readAnyDatabase" ]
       Replace <username> and <password> with a username and password of your choice.
    • For MongoDB version v3.2 and later:

       use admin
       user: "<username>",
       pwd: "<password>",
       roles: [ "readAnyDatabase", {role: "read", db: "local"} ]
       Replace <username> and <password> with a username and password of your choice.

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.

Configure Generic MongoDB Connection Settings

In the Configure your MongoDB Source page, specify the following:

Configure Source

  • Pipeline Name: A unique name for the Pipeline, not exceeding 255 characters.

  • General Connection Settings:

    • Paste Connection String:

      • Connection URI: The unique identifier for connecting to a MongoDB replica set or a sharded cluster.
    • Enter Connection Fields Manually:

      • Database Host: IP address or hostname of the database you want to access. To specify multiple database hosts, provide a comma-separated list of all IPs/DNS names.

        For example,,, is an example of a sharded cluster. Hevo always connects to a secondary instance.

        Note: For URL-based hostnames, exclude the protocol part, for example, mongodb:// or mongodb+srv://.

      • Database User: The authenticated user who has the permissions to read collections in your database. Read Set up permissions to read generic MongoDB databases.

      • Database Password: The password for the database user.

      • Database Port: The port on which your MongoDB server is listening for connections. Default value: 27017.

  • 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.

  • Use SSL: Enable this toggle option if you have enabled SSL at the MongoDB server end.

  • Select an Ingestion Mode: The desired mode by which you want to ingest data from the Source:

    • OpLog: Data is polled using MongoDB’s OpLog. The OpLog is a collection of individual, transaction-level details which help replicas sync data from the primary instance.

    Note: OpLogs are present in data/standalone primary instances and replicas.

    • Change Streams: MongoDB’s Change Streams enable 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.

  • Connect through SSH: Enable this toggle 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.

  • Advanced Settings:

    • Load All Databases: If enabled, Hevo fetches data from all the databases you have access to on the selected host. If disabled, provide the database name to fetch data from. In the case of the OpLog Pipeline mode, you can specify a comma-separated list of database names.

    • 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, prefixed with the respective database name. See 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 & CONTINUE to proceed for setting up the Destination.


  • 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
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.
Last updated on 21 Apr 2022