> For the complete documentation index, see [llms.txt](https://docs.rootcause.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rootcause.ai/data-sources-and-connectors/connectors/mongodb.md).

# MongoDB

Connect RootCause to MongoDB to import collections as tables. Nested documents are flattened into columns.

***

### Prerequisites

* A MongoDB connection string (standard or SRV)
* A user with read access to the collections you want
* Network access, including IP allowlisting for Atlas clusters

***

### Setting up the connection

1. In the Import Manager, click the **MongoDB** card
2. Enter the connection string:

| Field             | Description                                   | Example                                          |
| ----------------- | --------------------------------------------- | ------------------------------------------------ |
| Connection String | MongoDB connection URI, including credentials | `mongodb+srv://user:pass@cluster.mongodb.net/db` |

3. Click **Test connection** to verify, then **Save & continue**

***

### Importing data

1. Browse to the **Database** and **Collection**, or type their names.
2. Optionally set a **Query Filter**, a MongoDB query document such as `{ "status": "active" }`. Leave empty to import all documents.
3. Under **Advanced Options**, tune how documents become rows:
   * **Flatten Depth** (1 to 5): how many levels of nested objects are flattened into separate columns.
   * **Stringify Arrays**: convert arrays to JSON strings for tabular compatibility.

<figure><img src="https://1662811113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBXg3gZLR0e2Q8SzeQmql%2Fuploads%2Fgit-blob-bea7366579caf19171766320b3372db9f704e2d3%2Frc-mongodb-import-settings.png?alt=media" alt="MongoDB import settings with collection browser and query filter"><figcaption><p>Browse to a collection, optionally filter with a MongoDB query document.</p></figcaption></figure>

***

### Import modes

Full Import, Full Import + Live, Recent Rows and Time Period. Rolling windows are resolved by MongoDB itself. Query Directly is not available for MongoDB. See [Connectors](/data-sources-and-connectors/connectors.md).

***

### Troubleshooting

**Server selection timeout**

* For Atlas, add RootCause's address to the IP access list; check SRV DNS resolution

**Authentication failed**

* Confirm the auth database in the URI (often `?authSource=admin`)

**Columns missing**

* Raise the flatten depth, or check that the fields exist in the filtered documents
