# Integrate MongoDB with Databox

MongoDB is a widely used NoSQL database designed to store and manage large volumes of unstructured or semi-structured data. Unlike traditional relational databases, MongoDB uses a flexible, document-oriented data model that allows users to store data in JSON-like formats, making it ideal for applications that require dynamic, scalable data structures. It supports powerful querying and indexing capabilities, enabling fast retrieval of complex data. MongoDB is commonly used in modern web and mobile applications and integrates easily with various development and analytics tools.

## Connection

### Step 1: Prepare your MongoDB connection credentials

Before you connect MongoDB to Databox, gather the required connection details from your MongoDB setup or administrator. Here's where you can find each piece of information:

- **Host** — This is the server address where your MongoDB instance is hosted. For MongoDB Atlas (cloud service), you can find the hostname in your cluster dashboard under **Clusters > Connect > Connect to your application > Drivers**. For self-hosted MongoDB, ask your database admin or check your server configuration.
- **Port** — The port MongoDB listens on, usually `27017` by default. You can confirm this in your MongoDB configuration file (`mongod.conf`) or ask your admin.
- **MongoDB Protocol** — Typically `mongodb` for standard connections or `mongodb+srv` if you're using a DNS seedlist (common with Atlas). This info is part of the connection string provided by MongoDB Atlas or your admin.
- **MongoDB Auth Source** — The database that holds user credentials for authentication. Often this is `admin`, but it can also be the database name. Check your MongoDB user settings or connection string.
- **Username and Password** — Credentials created in MongoDB with the [necessary permissions](https://databox.com/metric-library/data-source/mongodb#technical-details). If you don't have these, request them from your database administrator.
- **Database Name** — The specific database you want to pull data from. This can be found in your MongoDB management tool or by asking your admin.
- **SSL and Certificate Details —** If your MongoDB requires SSL/TLS encryption, your admin should provide the SSL certificate files (`ssl-cert`, `ssl-key`, and optionally `ssl-ca`) and specify whether SSL verification is needed.


### Step 2: Whitelist Databox IP address

To allow Databox to securely connect to your MongoDB database, you need to whitelist the IP address that Databox uses. This grants permission for that IP to access your MongoDB instance.

**For MongoDB Atlas users:**

1. Log in to your [MongoDB Atlas](https://cloud.mongodb.com/) account.
2. Navigate to **Network Access** in the left sidebar.
3. Click **Add IP Address**.
4. Enter the IP address `52.4.198.118` (the IP address used by Databox).
5. Save the changes.


**For self-hosted MongoDB:** You'll need to update your server's firewall or network settings to allow incoming connections from the IP address `52.4.198.118`. Contact your network administrator if you're unsure how to do this.

### Step 3: Enter your MongoDB connection details in Databox

Once you have gathered all the necessary information (see [Step 1](#connection-prepare)), enter the following details into Databox to set up your connection:

- **Host** (required)
- **Port** (required)
- **MongoDB Protocol** (required)
- **MongoDB Auth Source**
- **Username**
- **Password**
- **Database Name** (required)
- **Name of the data source** (required)
- **SSL:** Enable or disable SSL encryption.
- **Time zone** (required)


If SSL is enabled, make sure to provide the required SSL certificate files:

- **SSL Certificate (ssl-cert)** (required)
- **SSL Certificate Key (ssl-key)** (required)


Optional SSL fields include:

- **Verify SSL Certificate**
- **SSL CA (ssl-ca)**


connect
Make sure all required fields are filled correctly to establish a successful connection.

If you've already established a connection, you can [reuse](/add-a-data-source) it to add new data sources to your Databox account.

## Datasets

The MongoDB integration supports the creation of [datasets](/understanding-datasets), which allow you to structure and format your MongoDB data for more flexible reporting in Databox. By organizing your data into a tabular format, datasets make it easier to filter, segment, and visualize key metrics across projects, clients, and team members.

### Steps to create a dataset:

1. **Select a collection:** Choose the MongoDB collection that contains the data you want to analyze. This collection acts as the source table for your dataset.
2. **Select a query method:** Databox supports two query methods to retrieve data:
  1. **Find:** Retrieves documents matching your query filter. Use this to return specific documents or entire collections.
  2. **Aggregate:** Runs aggregation pipeline queries for advanced filtering, grouping, and data transformation.
3. **Enter your query**


-   - To return **all documents** in the selected collection, choose the **Find** method and enter an empty query `{}`.
  - For **filtered searches or complex data manipulations**, enter a valid MongoDB query or aggregation pipeline in JSON format. Make sure your query matches the syntax requirements of the chosen method.


### Additional resources

- [MongoDB Query Filters](https://www.mongodb.com/docs/compass/query/filter/#set-query-filter) — Details on query syntax and filters.
- [MongoDB Aggregation Pipeline](https://www.mongodb.com/docs/manual/aggregation/#std-label-aggregation-pipeline-intro) — Guide to building aggregation pipelines for advanced queries.


Test your query in a MongoDB client or shell to ensure it returns the expected results before entering it in Databox.

## Resources

For comprehensive details on metrics, data availability, templates, specifications, usage guidelines, and other key information, refer to the resources listed below.

No, Databox currently does not support connections to MongoDB via VPC peering. You'll need to whitelist Databox's public IP addresses to allow access.

No, the MongoDB integration currently does not support query projections or additional query options such as `sort`, `limit`, or `skip`. Queries should return the full documents or aggregated results as needed. For more refined control over data, consider using aggregation pipelines.

No, private endpoint connections (such as AWS PrivateLink or Azure Private Endpoint) are not supported at this time. Please ensure your MongoDB instance is accessible over the public internet from the Databox IPs you whitelist.

 

Ask Genie
Get instant answers or help with your data using the in-app AI assistant.

Talk to an expert
For customers: Get help with your setup, strategy, or making the most of Databox.

Book a demo
New to Databox? See how it works and get guidance on getting started.

Send an email
Reach out to support for help with your account, data, or technical issues.