Set up MongoDB (self-managed)
Configure authentication for the MongoDB connector by creating a database user with appropriate permissions. This guide walks you through creating a database user with either a built-in role or a custom role, depending on your access requirements.
Before you begin
The database user you create must have read permission (the find action) on Collections to enable field extraction. Without this permission, only basic metadata is cataloged and column information isn't available. For more details, see What happens when read permission on Collections is missing.
Create database user
To enable Atlan to Crawl MongoDB (self-managed), you must create a database user in MongoDB. Atlan supports SCRAM authentication (SCRAM-SHA-1 and SCRAM-SHA-256) for fetching metadata from MongoDB. This method uses a username and password to authenticate.
- Built-in role
- Custom role
Use a built-in MongoDB role to grant read-only access to all databases in your MongoDB instance. For more information, see the MongoDB built-in roles documentation.
- Connect to your MongoDB instance using MongoDB shell or a MongoDB client.
- Select the authentication database (usually
admin):use admin - Create a database user with read-only access:
db.createUser({
user: "atlan_user",
pwd: "your_secure_password",
roles: [{ role: "readAnyDatabase", db: "admin" },
{ role: "clusterMonitor", db: "admin"}]
})- Replace
atlan_userwith your desired username andyour_secure_passwordwith a secure password. - The
readAnyDatabasebuilt-in role automatically includes all the privileges required by the connector, includinglistCollections,collStats, andfindactions across all databases. Whereas theclusterMonitorbuilt-in role is used to list all databases present in a cluster.
- Replace
Create a custom role to restrict access to specific databases and collections. For more information, see the MongoDB custom roles documentation.
- Connect to your MongoDB instance using MongoDB shell or a MongoDB client.
- Select the authentication database (usually
admin):use admin - Create a custom role with the following privileges. For details on the required privileges, see What privileges are required for a custom MongoDB role? in the FAQ.
db.createRole({
role: "atlan_integration",
privileges: [
{
resource: { cluster: true },
actions: ["listDatabases"]
},
{
resource: { db: "", collection: "" },
actions: ["listCollections"]
},
{
resource: { db: "", collection: "" },
actions: ["collStats"]
},
{
resoruce: { db: "", collections: ""},
actions: ["dbStats"]
},
{
resource: { db: "", collection: "" },
actions: ["find"]
}
],
roles: []
})- Replace the empty strings in the
resourcefields with specific database and collection names if you want to restrict access. Leave them empty to grant access to all databases and Collections.
- Replace the empty strings in the
- Create a database user and assign the custom role:
db.createUser({
user: "atlan_user",
pwd: "your_secure_password",
roles: [{ role: "atlan_integration", db: "admin" }]
})- Replace
atlan_userwith your desired username andyour_secure_passwordwith a secure password.
- Replace
Next steps
Now that you've set up the MongoDB connector and created a database user, you're ready to:
- Crawl MongoDB (self-managed): Configure and run metadata extraction from your MongoDB instance