# Send data to MongoDB

{% hint style="info" %}
See the changelog of this Data sink type [here](https://app.gitbook.com/s/zgCDPkYt2378cQelEdK8/mongodb-data-sink).
{% endhint %}

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FrcIktK3Jqr5c9QqUZivt%2Fmdbdark.png?alt=media&#x26;token=fcf6119d-a30f-47d1-9aa1-39eefac7b436" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2F4DKWM1QfLzF6eCnT6Du8%2Fmdb.png?alt=media&#x26;token=1fc4ff72-94eb-4c05-b5d3-77d5fcb16000" alt=""></picture><figcaption></figcaption></figure>

## Overview

Onum supports integration with [MongoDB](https://www.mongodb.com/).

MongoDB is a document database used to build highly available and scalable internet applications. Instead of using tables, as in a traditional relational database, MongoDB stores data in JSON documents organized into collections.

Select **MongoDB** from the list of Data sink types and click **Configuration** to start.

## Data sink configuration

Now you need to specify how and where to send the data, and how to establish a connection with Devo.

### Metadata

Enter the basic information for the new Data sink.

<table><thead><tr><th width="169.84765625">Parameters</th><th>Description</th></tr></thead><tbody><tr><td><strong>Name</strong><mark style="color:red;"><strong>*</strong></mark></td><td>Enter a name for the new Data sink.</td></tr><tr><td><strong>Description</strong> </td><td>Optionally, enter a description for the Data sink.</td></tr><tr><td><strong>Tags</strong> </td><td>Add tags to easily identify your Data sink. Hit the <code>Enter</code> key after you define each tag.</td></tr></tbody></table>

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FPdvanPgwv8iVHaGIR6eu%2Fdark-medium%20(12).png?alt=media&#x26;token=8157705e-34c6-414f-be5d-e38b168bb68d" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FNBMexTxFER6I3cWkJfTK%2Flight-medium%20(15)1.png?alt=media&#x26;token=ba174e4e-9324-4e1e-b973-c8d3a1d8f8be" alt=""></picture><figcaption></figcaption></figure>

***

### Metrics display

Decide whether or not to include this Data sink info in the metrics and graphs of the [**Home**](https://docs.onum.com/the-workspace/home) area.

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FfQTZeCKUmd7uXe46zKIq%2Fmemff.png?alt=media&#x26;token=c12b7e13-97a6-4898-abc9-c29756fb40bb" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2Fyunb1ES3IWOo7aI29zxN%2Fmememe.png?alt=media&#x26;token=6471f373-fc92-445e-a8a3-add634433133" alt=""></picture><figcaption></figcaption></figure>

***

### Configuration

Now add the configuration to establish the connection.

#### **Authentication Method**

Select one of the following options and complete the fields that appear to authenticate your connection:

<details>

<summary><strong>SRV Connection String</strong></summary>

Enter the **Host**<mark style="color:red;">**\***</mark> URL to connect to a MongoDB cluster using DNS-based seedlists. To get it:

1. Log in to MongoDB.
2. Choose the project that contains your cluster.
3. Click on the **Clusters** tab in the left-hand sidebar.
4. For the cluster you want to connect to, click the **Connect** button.
5. Select **Connect your application** for the connection method.
6. Copy the SRV Connection String, which should have the following format:&#x20;

```
mongodb+srv://:@cluster0.abcde.mongodb.net/myDatabase?retryWrites=true&w=majority
```

* Replace `username` and  `password` with your database credentials.
* Replace `myDatabase` with your target database name.

</details>

<details>

<summary><strong>Standard Connection String</strong></summary>

Enter the required **Host**<mark style="color:red;">**\***</mark> and **Port**<mark style="color:red;">**\***</mark> for a standard MongoDB connection string (non-SRV). To get the host:

1. Log in to MongoDB Atlas.
2. Select your **project** and **cluster**.
3. Click the **Connect** button for your cluster.
4. Choose **Connect your application**.
5. Click **I don’t have a driver** or scroll down to find the **standard connection string** option. You’ll see something like:

```plaintext
plaintextCopyEditmongodb://<username>:<password>@cluster0-shard-00-00.abcde.mongodb.net:27017,cluster0-shard-00-01.abcde.mongodb.net:27017,cluster0-shard-00-02.abcde.mongodb.net:27017/myDatabase?ssl=true&replicaSet=atlas-abcde-shard-0&authSource=admin&retryWrites=true&w=majority
```

* Replace `username` and  `password` with your database credentials.
* Replace `myDatabase` with your target database name.

</details>

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FKab8sNE1cl1ehnMKCd2B%2Fdark-medium%20(12).png?alt=media&#x26;token=05d4e5fd-1d2f-476c-8591-3430f9eff604" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FuNMi4cCKmVBjC2Mkam35%2Flight-medium%20(15)1.png?alt=media&#x26;token=8027e2a8-0c47-48a7-bee0-775ed8fd977c" alt=""></picture><figcaption></figcaption></figure>

#### **Authentication configuration**

Choose your required authentication **Type**<mark style="color:red;">**\***</mark> from the dropdown menu. Leave as **None** if no authentication is needed, or select from the following:

<table><thead><tr><th width="170.30859375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>SCRAM-SHA-256</strong></td><td><ul><li><strong>Username</strong><mark style="color:red;"><strong>*</strong></mark> - Enter your required username.</li><li><strong>Password</strong><mark style="color:red;"><strong>*</strong></mark> - Add your password from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one.</li><li><strong>Auth source</strong> - This is the database where your credentials are stored. For example:  <code>mongodb://username:password@host:port/?authSource=admin</code> </li></ul></td></tr><tr><td><strong>SCRAM-SHA-1</strong></td><td><ul><li><strong>Username</strong><mark style="color:red;"><strong>*</strong></mark> - Enter your required username.</li><li><strong>Password</strong><mark style="color:red;"><strong>*</strong></mark> - Add your password from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one.</li><li><strong>Auth source</strong> - This is the database where your credentials are stored. For example:  <code>mongodb://username:password@host:port/?authSource=admin</code> </li></ul></td></tr><tr><td><strong>x.509</strong></td><td><ul><li><strong>Client certificate</strong><mark style="color:red;"><strong>*</strong></mark> - Add your client certificate from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one.</li><li><strong>Client private key</strong><mark style="color:red;"><strong>*</strong></mark> - Add your private key from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one.</li><li><strong>CA certificate</strong><mark style="color:red;"><strong>*</strong></mark> - Add your CA certificate from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one.</li><li><strong>Auth source</strong> - This is the database where your credentials are stored. For example:  <code>mongodb://username:password@host:port/?authSource=admin</code> </li></ul></td></tr><tr><td><strong>AWS IAM</strong></td><td><ul><li><p><strong>Access key ID</strong><mark style="color:red;"><strong>*</strong></mark> - Add the access key ID from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one. The <strong>Access Key ID</strong> is found in the <strong>IAM Dashboard</strong> of the <strong>AWS Management Console</strong>. To get it:</p><ol><li>In the left panel, click on <strong>Users</strong>.</li><li>Select your <strong>IAM user</strong>.</li><li>Under the <strong>Security Credentials</strong> tab, scroll to <strong>Access Keys</strong>, and you will find existing <strong>Access Key IDs</strong> (but not the secret access key).</li></ol></li><li><strong>Access key</strong><mark style="color:red;"><strong>*</strong></mark> - Add the access key from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one. Under <strong>Access keys</strong>, you can see your <strong>Access Key IDs</strong>, but AWS <strong>will not show the Secret Access Key</strong>.  </li><li><p><strong>AWS session token</strong> - Add the AWS token from your <a href="../../../administration/global-settings/organization-settings/secrets-management">Secrets</a> or create one. To get it:</p><ol><li>Log in to the <strong>AWS Management Console</strong> via IAM Identity Center.</li><li>Click your <strong>username</strong> in the top-right corner and choose <strong>Command line or programmatic access</strong>.</li></ol></li><li><strong>Auth source</strong> - This is the database where your credentials are stored. For example:  <code>mongodb://username:password@host:port/?authSource=admin</code> </li></ul></td></tr></tbody></table>

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2Fwfql3gqBokTW7J9cfkNK%2F2dark.png?alt=media&#x26;token=d6d424e5-9af3-4d4b-a90e-337fe6fdae1c" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FasDKWXENMKcdxjr3zMJ4%2F1auth.png?alt=media&#x26;token=8eb78598-c85a-49bf-8413-d03644761217" alt=""></picture><figcaption></figcaption></figure>

#### Connection pool

<table><thead><tr><th width="170.32421875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Max pool size</strong></td><td>Set a limit on the number of events per pool. The minimum value is <code>0</code> and the maximum value is <code>10000</code>. The default value is <code>100</code>.</td></tr><tr><td><strong>Min pool size</strong></td><td>Set a minimum number of events per pool. The minimum value is <code>1</code> and the maximum value is <code>10000</code>. The default value is <code>10</code>.</td></tr><tr><td><strong>Max idle time</strong></td><td>Set the maximum amount of milliseconds a request can be idle before being considered timed out. The minimum value is <code>0</code> and the maximum value is <code>300000</code>. The default value is <code>30000</code>.</td></tr><tr><td><strong>Max simultaneous connections</strong></td><td>Enter a maximum allowance for the number of simultaneous connections. The minimum value is <code>1</code> and the maximum value is <code>1000</code>. The default value is <code>100</code>.</td></tr></tbody></table>

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FUSgppKugPYJD46lARauO%2Fdark-medium%20(12).png?alt=media&#x26;token=033b855b-88e0-4d32-a8fe-9492529b9760" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FsdXywgwifwiQKVjzVj0k%2Flight-medium%20(15)1.png?alt=media&#x26;token=9c2b703c-e43d-4c4e-9952-6be7426cfa61" alt=""></picture><figcaption></figcaption></figure>

#### Advanced Configuration

<details>

<summary><strong>Bulk configuration</strong></summary>

Toggle on this switch button to enable bulk settings. The values will be filled in by default; however, you can change them if needed.

<table><thead><tr><th width="169.73046875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Number of events</strong><mark style="color:red;"><strong>*</strong></mark></td><td>Enter a maximum for the number of events in a bulk. The minimum value is <code>1</code> and the maximum value is <code>1000</code>. The default value is <code>10</code>.</td></tr><tr><td><strong>Event time limit</strong><mark style="color:red;"><strong>*</strong></mark></td><td>Enter the number of seconds to wait before a bulk is triggered. The minimum value is <code>0</code> and the maximum value is <code>30000</code>. The default value is <code>1</code>.</td></tr><tr><td><strong>Max number of buffers</strong><mark style="color:red;"><strong>*</strong></mark> </td><td>Enter the maximum buffers that a system, application, or service is allowed to allocate or use for storing temporary data while processing it. The minimum value is <code>1</code> and the maximum value is <code>50</code>. The default value is <code>50</code>.</td></tr><tr><td><strong>Ordered</strong></td><td>You can toggle on this switch button to send the buffers in order.</td></tr></tbody></table>

</details>

<details>

<summary><strong>Bypass Document Validation</strong></summary>

Toggle on this switch button to allow MongoDB to skip any schema validation rules or constraints that would normally be enforced when inserting or updating a document.

</details>

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FOWx7jwO8Do3Kq84tHO03%2Fdaaar.png?alt=media&#x26;token=e95aa561-a65a-42fc-85d3-2ce58d7d9389" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FUNIfk7l1j3gD5kQh7O61%2Fac1.png?alt=media&#x26;token=075cb826-470b-4dcf-bb91-09f7cf35a923" alt=""></picture><figcaption></figcaption></figure>

Click **Finish** when complete. Your new Data sink will appear in the **Data sinks** area list.

## Pipeline configuration <a href="#pipeline-configuration" id="pipeline-configuration"></a>

When it comes to using this Data sink in a [Pipeline](https://docs.onum.com/the-workspace/pipelines), you must configure the following output parameters. To do it, simply click the Data sink on the canvas and select **Configuration**.

### Output configuration <a href="#output-configuration" id="output-configuration"></a>

<table><thead><tr><th width="170.32421875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Database</strong><mark style="color:red;"><strong>*</strong></mark></td><td>Choose the input field that contains the name of the database you want to write to.</td></tr><tr><td><strong>Collection</strong><mark style="color:red;"><strong>*</strong></mark></td><td>Choose the input field that contains the name of the collection you want to write to.</td></tr><tr><td><strong>Data</strong><mark style="color:red;"><strong>*</strong></mark></td><td>Choose the input field that contains the data to be sent to MongoDB.</td></tr></tbody></table>

<figure><picture><source srcset="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FfpOFXDuJI5qsUJV8v1IK%2Fdarkkm.png?alt=media&#x26;token=9ac6d208-7118-44c5-a182-bc61727e2144" media="(prefers-color-scheme: dark)"><img src="https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FCR3RH9qGgnkFgEkMspGO%2Fmdb1.png?alt=media&#x26;token=9c580884-32d4-4728-878d-6e45b0ab3ab6" alt=""></picture><figcaption></figcaption></figure>

Click **Save** to save your configuration.
