MongoDB
To add a new data source go to Settings > Data Sources > Add new data source and select MongoDB. Remember only admins can access workspace settings. Let’s see how to make the connection:
MongoDB Configuration
Getting started
This guide describes in details how you can configure MongoDB for integration with Latitude.
Create users
Run mongo shell, switch to admin database and create a READ_ONLY_USER
.
READ_ONLY_USER
will be used for Latitude integration. Please make sure that user
has read-only privileges.
mongo
use admin;
db.createUser({user: "READ_ONLY_USER", pwd: "READ_ONLY_PASSWORD", roles: [{role: "read", db: "TARGET_DATABASE"}]})
Make sure the user have appropriate access levels, a user with higher access levels may throw an exception.
Enable MongoDB authentication
Open /etc/mongod.conf and add/replace specific keys:
net:
bindIp: 0.0.0.0
security:
authorization: enabled
Binding to 0.0.0.0
will allow to connect to database from any IP address.
The last line will enable MongoDB security. Now only authenticated users will be able to access the database.
TLS/SSL on a Connection
It is recommended to use encrypted connection. Connection with TLS/SSL security protocol for MongoDb Atlas Cluster and Replica Set instances is enabled by default. To enable TSL/SSL connection with Standalone MongoDb instance, please refer to MongoDb Documentation.
Latitude Configuration
Fill in the required fields user, password, database and auth source (defaults to admin
):
Fill in all the required fields
- Alias → (Required) The name you'll see for this source in Latitude. This doesn’t affect anything in your database.
- User → (Required) The user credentials to authenticate in your MongoDB. We recommend use an user with read-only role.
- Password → (Required) The password to authenticate in your MongoDB.
- Database → (Required) The name of the database you want to import to Latitude.
- Auth source → (Required) Your Auth source, default it's
admin
. - Instance type → (Required) Select the instace configuration of your MongoDB. There are 3 options: Standalone, Replica set and Atlas cluster.
Atlas Cluster
- Cluster URL → The URL to the cluster that contains the database you want to add.
Click on
Add data source
How to get the Cluster URL in MongoDB Atlas
Go to the project that contains the data you want to add
Click on Database on the left sidebar
Click on the Connect button in the cluster
A window will appear. Now click on Drivers
It will appear 3 steps, let's focus on the third one called "3. Add your connection string into your application code"
In the snippet code appears your cluster URL. It's the part after
...<password>@
and before/?retryWr...
so in this case our URL iscluster-latitude.tkvnfk2.mongodb.net
How to get the Database name in MongoDB Atlas
Go to the project that contains the data you want to add
Click on Database on the left sidebar
Click on the name of the cluster that contains the data you want to add
Click on
Collections
in the horizontal menuThe database names of your cluster will appear on the right. Select the one you want to add and enter it in the Database field in Latitude
How to add Latitude IP to MongoDB Atlas whitelist
Go to the project that contains the data you want to add
Click on Network Access on the left sidebar
Make sure you are in the IP Access List
Click on the
Add IP Address
buttonAdd our IP
18.193.205.15/32
to the Access List Entry field and the desired commentClick Confirm and done! You are now ready to connect to Latitude
And you are done! MongoDB is connected to Latitude.