MongoDB
Minimum MongoDB roles for each Nilus pipeline mode: batch read and write, change-stream CDC, and metadata ingestion.
This page documents the minimum MongoDB grants a platform or database administrator must provision for Nilus to run batch, CDC, and metadata pipelines against a MongoDB depot. It is validated against Nilus 2.0.
Pipeline modes supported
type: batch
mongodb://
Full or incremental reads and writes
type: cdc
debezium+mongodb://
Change stream capture (requires replica set or sharded cluster)
type: metadata
metadata+mongodb://
Metadata ingestion
Nilus supports two write strategies for MongoDB destinations: replace and merge. It does not support append.
Read data: MongoDB as source (type: batch)
Nilus uses this path when the depot is referenced in source.address of a pipeline config. Nilus reads documents from the target collection using the MongoDB driver.
Minimum grants
db.getSiblingDB("admin").createUser({
user: "nilus_reader",
pwd: "<password>",
roles: [
{ role: "read", db: "<database_name>" }
]
})The built-in read role covers find, listCollections, listIndexes, dbStats, and collStats on the target database.
To restrict access to a specific collection, grant a custom role with only find on that collection instead of the database-level read role.
Write data: MongoDB as destination (type: batch, type: cdc)
Nilus uses this path when the depot is referenced in sink.address of a pipeline config.
Minimum grants
Grants by write strategy
replace
delete_many({}) + insert_many
readWrite
merge
upsert (insert + update)
readWrite
The built-in readWrite role covers all required operations for both strategies. Writes need no custom role.
CDC source: MongoDB (type: cdc)
Nilus captures document-level changes through MongoDB change streams, not direct oplog reads. The Debezium MongoDB connector manages the change stream cursor and offset tracking.
Infrastructure prerequisite
MongoDB must run as a replica set or sharded cluster. Standalone servers do not support change streams and are not supported.
Set the replicaSet parameter in depot spec.params.
Connector behavior: allChangesForCluster: true
The Nilus Debezium MongoDB connector always opens a deployment-wide change stream using { $changeStream: { allChangesForCluster: true } }, executed as a collectionless aggregate against $db: admin. This applies even when only a single collection (for example, nilusdb.orders) is targeted: Debezium filters client-side after opening the cluster-wide cursor.
A database-scoped read role alone is not sufficient. The CDC user must have changeStream and find privileges at the all-databases level, not just on the captured database. This was confirmed empirically: with only read on the source database, the connector fails with error 13 (Unauthorized) on the admin aggregate. The pipeline succeeded only after cluster-wide privileges were granted.
Minimum grants
For a sharded cluster, add read access to the config database:
clusterMonitor is required to run the hello command and read replica set and cluster metadata. Without it, the Debezium connector cannot resolve the cluster topology at startup.
Because Nilus uses allChangesForCluster: true, clusterMonitor alone is not sufficient. The CDC user also needs cluster-wide changeStream and find privileges. The mandatory minimum, regardless of how many databases are captured, is:
Metadata ingestion: MongoDB source connector (type: metadata)
Nilus uses this path when the depot is referenced in source.address of a type: metadata pipeline. Nilus drives the MongoDB source connector.
Workflows that run for MongoDB
Nilus conditionally gates metadata workflow steps based on the source type. For MongoDB, only the following steps run:
Metadata (collections, schemas, columns)
Yes
Always
Profiler (row counts, sample data)
Yes
deep mode only
Classification
Yes
deep mode only
Lineage
No
Skipped: not supported for MongoDB
Usage
No
Skipped: not supported for MongoDB
Lineage and usage are permanently excluded for MongoDB at the orchestration level (nilus-domain.yaml), regardless of permissions.
Minimum grants
The read role covers both required operations:
findon collectionslistCollectionson the database
No system table access or additional grants are needed for any MongoDB metadata workflow.
Permission matrix
Read (source, batch)
read
Target database
Write, replace
readWrite
Target database
Write, merge
readWrite
Target database
CDC source
read + clusterMonitor
Captured database + admin
CDC source (sharded)
read + clusterMonitor + read
Captured database + admin + config
Metadata / profiler / classification
read
Target database
Notes
Replica set is required for CDC. Standalone MongoDB servers do not support change streams. Set the
replicaSetparameter in the depot specparams.authSourcemust match the user's admin database. If the user is created in theadmindatabase, setparams.authSource = "admin". A mismatchedauthSourcecauses authentication failures.appendis not a supported write strategy. Onlyreplaceandmergeare supported for MongoDB destinations.MongoDB has no lineage or usage workflow. Nilus excludes these workflows at the orchestration level, and no additional grants enable them.
readWritecovers all write operations. Bothreplace(delete and insert) andmerge(upsert) are covered by the built-inreadWriterole.
Last updated
Was this helpful?