Prerequisites
- MongoDB version ≥ 5.0
- A MongoDB user with sufficient privileges to create database users and collections
MongoDB Atlas Setup
1. Grant Database Access
- Configure one of the Connection Options to ensure Streamkap can reach your database.
2. Create Database User
MongoDB Atlas
- Log in to MongoDB Atlas and navigate to the MongoDB cluster.
- In the left-hand navigation menu, go to Security > Database Access.
- Click New Database User.
- Choose the password authentication method.
-
Enter the username and password for the new Streamkap user (e.g.
streamkap_user). - In the Database User Privileges drop-down menu, select Grant Specific User Privileges.
-
Under Specific Privileges, add the following roles/privileges:
readAnyDatabasereadon thelocaldatabase
- Click Add User.
MongoDB Shell
- Using MongoDB Shell, connect to your primary node or replica set.
- Create a user for Streamkap using the script below. Replace password with your choice.
3. Enable Snapshots
To backfill your data, the Connector needs to be able to perform snapshots. See Snapshots & Backfilling for more information. You will need to create the collection and give necessary permissions to thestreamkap_user. The Connector will use this collection for managing snapshots.
This collection can exist in a different database (on the same MongoDB cluster) to the database Streamkap captures data from.
MongoDB Atlas
- Navigate to the MongoDB cluster.
-
Navigate to Collections and create a new collection in the database by clicking the
+button next to the database name.- Name the collection
streamkap_signal. - Give the Streamkap user permissions to
readWriteon thestreamkap_signalcollection. - Return to the Database User Privileges drop-down menu, select Grant Specific User Privileges.
- Under Specific Privileges, add the following roles/privileges:
readWrite@{database}.streamkap_signal
- Under Specific Privileges, add the following roles/privileges:
- Name the collection
MongoDB Shell
4. Heartbeats
MongoDB uses change streams to track changes. While change streams use resume tokens to track position, these tokens can expire or become invalidated—particularly on clusters with high write activity or when using custom aggregation pipelines that filter events. Heartbeats ensure the Connector receives regular change events, keeping resume tokens fresh and providing liveness monitoring. There are two layers of heartbeat protection:Layer 1: Connector heartbeats (enabled by default)
The Connector periodically emits heartbeat messages to an internal topic, even when no actual data changes are detected. This keeps offsets fresh and prevents staleness. No configuration is necessary for this layer; it is automatically enabled. We recommend keeping this layer enabled for all deployments.Layer 2: Source database heartbeats (recommended)
Why we recommend configuring Layer 2Layer 2 is especially important when:
- Your database has low or intermittent traffic
- You use custom aggregation pipelines that filter out many events
- You need reliable liveness monitoring
Create the heartbeat collection
Create a collection to store heartbeat documents. This can be in the same database you’re capturing or a dedicated
streamkap database.Using MongoDB Atlas UI:- Navigate to your cluster and click Browse Collections
- Click Create Database or select an existing database
- Create a collection named
streamkap_heartbeat
Grant permissions to the Streamkap user
Ensure the Streamkap user has
read access to the heartbeat collection.Using MongoDB Atlas UI:- Go to Security > Database Access
- Edit the
streamkap_user - Under Specific Privileges, add:
[email protected]_heartbeat
Create an Atlas Scheduled Trigger
- In MongoDB Atlas, go to App Services (or Triggers in the left menu)
- Click Create a Trigger
- Select Scheduled trigger type
- Configure the trigger:
- Name:
streamkap_heartbeat_trigger - Schedule Type: Basic
- Repeat once by: Minute
- Every: 1 minute(s)
- Name:
- In the Function section, select Function and create a new function:
- Click Save
Atlas App Services usage and costThe scheduled trigger counts as an App Services Request. With a 1-minute interval:
- ~1,440 requests/day (60/hour × 24 hours)
- Daily free tier: 50,000 requests—this heartbeat uses only ~3% of the free allowance
- Cost if exceeding free tier: $0.000002 per request
5. Obtain Connection String
You’ll need the connection string for setting up the Connector in Streamkap.MongoDB Atlas
- Log in to MongoDB Atlas and navigate to the cluster to which Streamkap should connect.
- Click Connect.

- Click Connect your Application.

- Copy the connection string.

MongoDB Shell
- Connect to your replica set or primary node using the MongoDB shell as an Admin user.
-
Run
db.getMongo()method to return your connection string.-
We recommend the connection string have the following parameters. They will be added automatically if not included:
w=majorityreadPreference=primaryPreferred
-
We recommend the connection string have the following parameters. They will be added automatically if not included:
For information on accepted connection string formats, please see MongoDB - Connection String Formats
Streamkap Setup
Follow these steps to configure your new connector:1. Create the Source
- Navigate to Add Connectors.
- Choose MongoDB.
- Select MongoDB Atlas.
2. Connection Settings
- Name: Enter a name for your connector.
- Connection String: Copy the connection string from earlier steps but replace username and password in the string with the one you created earlier.
-
Array Encoding: Specify how Streamkap should encode MongoDB array types.
Arrayencodes them as a JSON array but requires all elements in the arrays to be of the same type e.g. array of integers.Array_Stringencodes them as a JSON string and must be used if the MongoDB arrays have mixed types. -
Nested Document Encoding: Specify how Streamkap should encode nested documents.
Documentencodes them as JSON objects but may be problematic for complex (e.g. multiple levels of nested sub documents and arrays, sub arrays of nested documents) documents.Stringencodes them as a JSON string and we recommend it if the MongoDB nested documents are complex. -
Connect via SSH Tunnel: The Connector will connect to an SSH server in your network which has access to your database. This is necessary if the Connector cannot connect directly to your database.
- See SSH Tunnel for setup instructions.
3. Snapshot Settings
- Signal Table Database: Streamkap will use a collection in this database to manage snapshots. See Enable Snapshots for more information.
4. Database and Collection Capture
- Add Database/Collections: Specify the database(s) and collection(s) for capture.
- You can bulk upload here. The format is a simple list of databases and collections, with each entry on a new row. Save as a
.csvfile without a header. - If you configured Layer 2 heartbeats, include the heartbeat collection (e.g.,
streamkap.streamkap_heartbeat). See Heartbeats for setup instructions.
- You can bulk upload here. The format is a simple list of databases and collections, with each entry on a new row. Save as a
Have questions? See the MongoDB Source FAQ for answers to common questions about MongoDB sources, troubleshooting, and best practices.