> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Step-by-step guide on how to set up MongoDB Atlas as a source for ClickPipes

# MongoDB Atlas source setup guide

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

<h2 id="enable-oplog-retention">
  Configure oplog retention
</h2>

Minimum oplog retention of 24 hours is required for replication. We recommend setting the oplog retention to 72 hours or longer to ensure that the oplog isn't truncated before the initial snapshot is completed. To set the oplog retention via UI:

1. Navigate to your cluster's `Overview` tab in the MongoDB Atlas console and click on the `Configuration` tab.

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-cluster-overview-configuration.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=8a88b2db4e601400b71c828709f2f6a6" alt="Navigate to cluster configuration" size="lg" border width="2496" height="1094" data-path="images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-cluster-overview-configuration.png" />

2. Click `Additional Settings` and scroll down to `More Configuration Options`.

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-expand-additional-settings.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=4cdebb6a84ac2e68c3fbd3df907e580b" alt="Expand additional settings" size="lg" border width="2106" height="1282" data-path="images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-expand-additional-settings.png" />

3. Click `More Configuration Options` and set the minimum oplog window to `72 hours` or longer.

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-set-retention-hours.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=fb05662a62d88887f7d37ac91ec19c8b" alt="Set oplog retention hours" size="lg" border width="2102" height="894" data-path="images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-set-retention-hours.png" />

4. Click `Review Changes` to review, and then `Apply Changes` to deploy the changes.

<h2 id="configure-database-user">
  Configure a database user
</h2>

Once you're logged in to your MongoDB Atlas console, click `Database Access` under the Security tab in the left navigation bar. Click on "Add New Database User".

ClickPipes requires password authentication:

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-add-new-database-user.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=a9a4652a3587f4ed39a4405c97134359" alt="Add database user" size="lg" border width="1846" height="1356" data-path="images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-add-new-database-user.png" />

ClickPipes requires a user with the following roles:

* `readAnyDatabase`
* `clusterMonitor`

You can find them in the `Specific Privileges` section:

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-database-user-privilege.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=05d0c112f22ef9769a6c7ad72cdaa445" alt="Configure user roles" size="lg" border width="1878" height="1020" data-path="images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-database-user-privilege.png" />

You can further specify the clusters/instances you wish to grant access to ClickPipes user:

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-restrict-access.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=eb621b4f1020e0198a154ef2edadf7c2" alt="Restrict cluster/instance acces" size="lg" border width="1522" height="730" data-path="images/integrations/data-ingestion/clickpipes/mongodb/mongo-atlas-restrict-access.png" />

<h2 id="whats-next">
  What's next?
</h2>

You can now [create your ClickPipe](/integrations/clickpipes/mongodb/index) and start ingesting data from your MongoDB instance into ClickHouse Cloud.
Make sure to note down the connection details you used while setting up your MongoDB instance as you will need them during the ClickPipe creation process.
