Connect MongoDB to Rig
Mirror the collections of a MongoDB database, on Atlas or self-hosted, into your warehouse. Each collection becomes a table, and nested arrays land as child tables. Rig connects with a connection string and a read-only user.
Before you start
- Create a database user with read-only access. The role on that user is what limits what Rig can read.
- On Atlas, add Rig's IP address to Network Access:
54.76.207.130, or35.153.75.215for US workspaces. - A self-hosted server needs a public address. Rig never connects to private ones, and certificate checks cannot be turned off.
Step 1: Prepare your MongoDB connection
- Create a read-only database user for Rig.
- On Atlas, go to
Database & Network AccessthenIP Access Listand add the Rig IP address that matches your workspace. - Get the connection string. On Atlas, use
ConnectthenDrivers. It looks likemongodb+srv://user:password@cluster.example.mongodb.net/?authSource=admin. - Percent-encode any special characters in the password.
Use a read-only user
The Collections field only limits what Rig lists. The user's role is the actual boundary on what can be read.
Step 2: Connect it in Rig
Adding a source needs a workspace owner, or a role with the Manage connections permission, on a workspace where you manage your own connections. If the Connectors tab says “Data ingestion for this workspace is managed by Rig”, ask an owner or Rig support to add the source.
- In Rig, open
Connections, choose theConnectorstab and go toSources & actions. - Search for MongoDB / MongoDB Atlas, open the card and click
Connect. - Connection string: paste the full
mongodb://ormongodb+srv://string, with the read-only user's credentials. - Database: the database to mirror, such as
app. - Collections: leave it blank to offer every collection, or list names such as
users,ordersto limit what Rig lists and syncs. - Click
Continue. Rig checks the credentials and lists the streams it can reach, so choose the ones you want and clickConnect. - The source then syncs on its schedule, which is nightly unless you change it. To load data straight away, click
Syncon its row;Testpulls a small sample first if you want to check the connection.
What Rig pulls in
MongoDB lands in its own mongodb schema in your warehouse:
- One table per collection: the collections come from your own database, so the tables depend on what it holds.
- Child tables: nested arrays land as child tables.
Collections with an updated-at field sync edits as well as new documents. Append-only collections sync new documents by _id. Rig picks the mode per collection and shows it when you choose collections.
Good to know
- Reads go to a secondary when the cluster has one, so a sync does not load the primary. A
readPreferencein your connection string is honoured. - Connections use TLS.
mongodb+srv://always does, and a plainmongodb://server can opt out withtls=falseonly if it is on a public address. - Edit tracking needs an indexed updated-at field whose values are all dates. Collections without one use a different read mode.
- To disconnect MongoDB, click the bin icon on the source's row under
Sources & actions. Only whoever connected the source or a workspace owner can do this, and data already synced stays in the warehouse.
What people use this for
- Analyse application data without querying production
- Flatten nested documents into queryable tables
- Join application data to CRM and billing