How to do connection overrides on a MongoDB connection
The supported MongoDB data types and the respective Luzmo data type they are mapped to
1. How to setup a MongoDB connection
To make a connection to MongoDB, navigate to the Connections page, select New Connection, then MongoDB from the New Connection modal. You'll be asked to provide a host, key and token:
host: database location (including port number) and database.
eg. mongodb+srv://burrito.mongodb.net/my-mongo-database for MongoDB Atlas
eg. public_host_url:port/my-mongo-database for MongoDB databases running on other servers (we will prepend the connection string with mongodb://)
key: the username of the MongoDB user. We advise you to use a dedicated read-only technical user.
token: the password of the MongoDB user.
Notes:
We only support TLS1.2 connections as part of our security best practices, this ensures that all communication between our platform and your database (e.g. data in transit) will be encrypted!
To ensure that e.g. only the Luzmo application can access your MongoDB instance, it is highly recommended to whitelist Luzmo's range of static IP addresses.
You should whitelist Luzmo's range of IP addresses as described here.
If you use a global user (one defined on the 'admin' database, that has access to all databases), use a connection string that explicitly sets the authentication database, like: mongodb+srv://burrito.mongodb.net/my-mongo-database?authSource=admin
If you want to separate the workload of the analytical queries run by us from your main application workload, you could set up a separate read-replica.
Because MongoDB is schemaless (meaning any document within a MongoDB collection could have a varying sets of fields with different data types for each field) Luzmo infers the structure of a dataset and the data types of the columns from the first 1000 records in the dataset. The fallback data type is "hierarchy".
You cannot change the columns' base type manually in Luzmo. We run a metadata sync every few hours to keep the structure in Luzmo the same as the structure in the database. In case you have done adaptations to the dataset structure and would like to trigger the metadata sync manually, you can do so from the dataset details page which you can reach by clicking the More Info "i" icon .
Please refer to the examples in our developer documentation to find out how to create a connection to MongoDB via our API.
2. How to add datasets
Once you have connected your MongoDB you can add datasets (collections) as explained here. You can select one or multiple datasets (collections) as available in your Clickhouse and link them in Luzmo to ensure they can be used together in a dashboard. Also make sure to check out this article on Preparing your data for analytics.
When generating an Authorization token to grant a user acces to your embedded dashboards it is possible to override the data source properties in the authorization request to dynamically use different properties. Find out more about connection overrides.
The fields available for overriding a MongoDB connection are as follows:
Connection ID: The ID of the Connection to be overridden. Retrieve the ID to specify as detailed here.
host: The new database host to connect to.
key: The username of the MongoDB user (use a dedicated read-only technical user).
token: The password of the MongoDB user.
datasets: List of dataset-level overrides. Useful if you want to override only a single dataset in your dashboard or if you have a separate table per client.
schema: The new database to query.
table: The new MongoDB table (collection) to query.