MongoDB Atlas feature snapshot

A high-level look at Stitch's MongoDB Atlas (v1.0) integration, including release status, useful links, and the features supported in Stitch.

STITCH
Release Status

Open Beta

Supported By

Stitch

Stitch Plan

Standard

Supported Versions

2.6 through 4.0

CONNECTION METHODS
SSH Connections

Unsupported

SSL Connections

Supported

REPLICATION SETTINGS
Anchor Scheduling

Supported

Advanced Scheduling

Supported

Table-level Reset

Supported

Configurable Replication Methods

Supported

REPLICATION METHODS
Log-based Replication

Supported

Key-based Replication

Supported

Full Table Replication

Supported

DATA SELECTION
Table Selection

Supported

Column Selection

Supported

View Replication

Unsupported

TRANSPARENCY
Extraction Logs

Supported

Loading Reports

Supported

Connecting MongoDB Atlas

MongoDB Atlas setup requirements

To set up MongoDB Atlas in Stitch, you need:

  • A Standard or higher Stitch plan. While those currently in the Free Trial will also be able to set up MongoDB Atlas, replication will be paused until a Standard plan or higher is selected after the trial ends.
  • Privileges in MongoDB Atlas that allow you to create/manage users. This is required to create the Stitch database user.

  • A MongoDB Atlas database using a version between 2.6 and 4.0. While older versions may be connected to Stitch, we may not be able to provide support for issues that arise due to unsupported versions.

    We recommend always keeping your version current as a best-practice. If you encounter connection issues or other unexpected behavior, verify that your MongoDB Atlas version is one supported by Stitch.


Step 1: Configure database connection settings

In this step, you’ll configure your MongoDB Atlas cluster to allow traffic from Stitch to access it. This is accomplished by whitelisting Stitch’s IP addresses in the cluster’s IP address whitelist in MongoDB Atlas.

  1. In MongoDB Atlas, navigate to the project containing the cluster you want to connect to Stitch. You can do this using the Context menu in the top left corner of the page.
  2. Click Network Access in the Security section on the left side of the page.
  3. Click + Add IP address on the Network Access page.

Add Whitelist Entry window for whitelisting IP addresses in MongoDB Atlas

  1. Fill in the fields in the Add Whitelist Entry window as follows:
    • Whitelist Entry: Paste one of the following IP addresses:

      • 52.23.137.21/32

      • 52.204.223.208/32

      • 52.204.228.32/32

      • 52.204.230.227/32

    • Comment: Enter Stitch.

  2. Click Confirm.
  3. Repeat steps 3-5 until all of Stitch’s IP addresses have been added:

List of whitelisted IP addresses in the Network Access page of MongoDB Atlas

Step 2: Create a Stitch database user

  1. In MongoDB Atlas, navigate to the project containing the cluster you want to connect to Stitch. You can do this using the Context menu in the top left corner of the page.
  2. Click Database Access in the Security section on the left side of the page.
  3. Click the + Add new user button on the Database Access page.

  1. Fill in the fields as follows in the Add New User window that displays:
    • Username: Enter stitch.
    • Password: Enter a secure password for the Stitch user.
    • User Privileges: Select Only read any database.
  2. Click Add User when finished.

See the Privileges list tab for an explanation of why these permissions are required by Stitch.

In the table below are the database user privileges Stitch requires to connect to and replicate data from a MongoDB Atlas database.

Privilege name Reason for requirement
Only read any database

Required to read data from databases in the cluster. This is equivalent to the readAnyDatabase role.

Step 3: Connect Stitch

In this step, you’ll complete the setup by entering the database’s connection details and defining replication settings in Stitch.

In this section:

Step 3.1: Locate the database connection details in Mongo Atlas

  1. In MongoDB Atlas, click Clusters under the Atlas section on the left side of the page.
  2. Locate the cluster you want to connect to Stitch.
  3. Click Connect. This will display a window with several connection options. Connect with the Mongo Shell connection option in MongoDB Atlas
  4. Click Connect with the Mongo Shell.
  5. Click I have the Mongo Shell installed.
  6. For Select your Mongo Shell version, select 3.4 or earlier.
  7. Copy the connection string. It will look something like this:
    mongo "mongodb://test-shard-00-00-ddreq.mongodb.net:27017,test-shard-00-01-ddreq.mongodb.net:27017/test?replicaSet=test-shard-0" --ssl --authenticationDatabase admin --username <username> --password <password>
    
  8. Locate the following in the connection string:

    • Host (Endpoint): This is the address of the instance you’re connecting to Stitch. It will be formatted like this: <some-address>.mongodb.net. In this example, the host is test-shard-00-00-ddreq.mongodb.net.
    • Port: This is the port used to connect to the database. It follows the host string, separated by a colon (:). The default is 27017, which is what this example is also using.
    • Replica set: This is used to perform Log-based Incremental Replication. Locate replicaSet in the connection string - the value that follows is the name of the replica set. In this example, the replica set is test-shard-0.

Step 3.2: Define the database connection details

  1. If you aren’t signed into your Stitch account, sign in now.
  2. On the Stitch Dashboard page, click the Add Integration button.

  3. Locate and click the MongoDB icon.
  4. Fill in the fields as follows:

    • Integration Name: Enter a name for the integration. This is the name that will display on the Stitch Dashboard for the integration; it’ll also be used to create the schema in your destination.

      For example, the name “Stitch MongoDB Atlas” would create a schema called stitch_mongodb_atlas in the destination. Note: The schema name cannot be changed after the integration is saved.

    • Host (Endpoint): Paste the Host (Endpoint) you retrieved in the previous step (3.1). This should be similar to <some-address>.mongodb.net.

    • Port: Paste the Port you retrieved in the previous step (3.1). The default is 27017.

    • Username: Enter the Stitch MongoDB Atlas database user’s username.

    • Password: Enter the password for the Stitch MongoDB Atlas database user.

    • Authentication Database: This must be admin. This is the name of the Stitch user’s authentication database. This is the name of the database where the Stitch database user was initially created.

    • Replica Set: Optional. The name of the replica set you retrieved in the previous step (3.1) to be used for Log-based Incremental Replication.

    • Include MongoDB database names in destination tables: Checking this setting will include database names from the source database in the destination table name - for example: <source_database_name>__<collection_name>.

      Stitch loads all selected replicated collections to a single schema, preserving only the collection name. If two collection canonicalize to the same name - even if they’re in different source databases - name collision errors can arise. Checking this setting can prevent these issues.

      Note: This setting can not be changed after the integration is saved. Additionally, this setting may create table names that exceed your destination’s limits. For more info, refer to the Database Integration Table Name Collisions guide.

Step 3.3: Define the SSL connection details

Click the Connect using SSL checkbox. MongoDB Atlas requires SSL to connect successfully.

Step 3.4: Define Log-based Replication setting

In the Log-based Replication section, you can set this as the integration’s default Replication Method.

When enabled, tables that are set to replicate will use Log-based Incremental Replication by default. If you don’t want a table to use Log-based Incremental Replication, you can change it in the Table Settings page for that table.

If this setting isn’t enabled, you’ll have to select a Replication Method for each table you set to replicate.

Step 3.5: Create a replication schedule

In the Replication Frequency section, you’ll create the integration’s replication schedule. An integration’s replication schedule determines how often Stitch runs a replication job, and the time that job begins.

MongoDB Atlas integrations support the following replication scheduling methods:

To keep your row usage low, consider setting the integration to replicate less frequently. See the Understanding and Reducing Your Row Usage guide for tips on reducing your usage.

Step 3.6: Save the integration

When finished, click Check and Save.

Stitch will perform a connection test to the MongoDB Atlas database; if successful, a Success! mesage will display at the top of the screen. Note: This test may take a few minutes to complete.

Step 4: Select data to replicate

The last step is to select select the collections and fields you want to replicate.

When you track a collection, Stitch will use the default Replication Method selected in the Integration Settings page. You can choose a different Replication Method for individual collections during this process.

You can select collections and fields by:

  1. In the Integration Details page, click the Collections to Replicate tab.
  2. Locate a collection you want to replicate.
  3. Click the checkbox next to the object’s name. A green checkmark means the object is set to replicate.
  4. If there are child objects, they’ll automatically display and you’ll be prompted to select some.
  5. After you set a collection to replicate, the Settings page will display. Note: When you track a table, by default all fields will also be tracked.

  6. In the Settings page, define the collection’s Replication Method and, if using Key-based Incremental Replication, its Replication Key.

  7. Optional: Select or exclude fields by entering a projection query in the Fields to Replicate section. Refer to the Selecting MongoDB Fields Using Projection Queries guide for instructions and examples.

  8. Repeat this process for every collection you want to replicate.

  9. Click the Finalize Your Selections button to save your data selections.

Initial and historical replication jobs

After you finish setting up MongoDB Atlas, its Sync Status may show as Pending on either the Stitch Dashboard or in the Integration Details page.

For a new integration, a Pending status indicates that Stitch is in the process of scheduling the initial replication job for the integration. This may take some time to complete.

Free historical data loads

The first seven days of replication, beginning when data is first replicated, are free. Rows replicated from the new integration during this time won’t count towards your quota. Stitch offers this as a way of testing new integrations, measuring usage, and ensuring historical data volumes don’t quickly consume your quota.


MongoDB Atlas Replication

MongoDB Replication Keys

Unlike Replication Keys for other database integrations, those for MongoDB have special considerations due to MongoDB functionality. For example: MongoDB allows multiple data types in a single field, which can cause records to be skipped during replication.

Refer to the MongoDB Replication Keys guide before you define the Replication Keys for your collections, as incorrectly defining Replication Keys can cause data discrepancies.

Heavily nested data and destination column limits

MongoDB documents can contain heavily nested data, meaning an attribute can contain many other attributes.

If your destination doesn’t natively support nested data structures, Stitch will de-nest them to load them into the destination. Depending on how deeply nested the data is and the per table column limit of the destination, Stitch may encounter issues when loading heavily nested data.

Refer to the Nested Data Structures guide for more info and examples.


Troubleshooting

Fields Missing from Replication Key Menu

If fields you expect to see are missing from a collection’s Replication Key menu, it may be that the fields aren’t indexed. Refer to the Mongo Replication Keys guide for more info.


Questions? Feedback?

Did this article help? If you have questions or feedback, feel free to submit a pull request with your suggestions, open an issue on GitHub, or reach out to us.