MongoDB
Configuration reference for the MongoDB metadata source: supported stages, source options, required roles, and troubleshooting.
MongoDB is supported as a metadata source. A spec.type: metadata pipeline introspects a MongoDB deployment and publishes source context, including databases, collections, inferred fields, and profiles, into the DataOS metadata catalog without copying any documents. Because MongoDB is schema-less, Nilus infers each collection's field structure by sampling documents.
For batch row movement out of MongoDB, see MongoDB (batch). For change data capture, see MongoDB (CDC). For the field-by-field authoring contract, see Understanding metadata pipeline config.
Metadata stages
service_type: mongodb supports metadata, profiler, and classification only.
metadata
shallow, deep
Databases, collections, and the fields inferred from sampled documents (including nested documents and arrays).
profiler
deep
Per-field statistics computed from a document sample (value counts, null ratios, basic distributions) and collection-level document counts.
classification
deep
Auto-classification tags applied to fields from sampled values (PII heuristics).
lineage
Not applicable
Not supported for MongoDB.
usage
Not applicable
Not supported for MongoDB.
Because lineage and usage are not applicable, a shallow MongoDB pipeline effectively runs the metadata stage only, and a deep pipeline runs metadata + profiler + classification. mode is still required by the schema. query_log_duration and result_limit have no effect on MongoDB.
Asset hierarchy
The catalog models a MongoDB server as one database named default. Real Mongo databases appear one level down as schemas, and collections as tables. Nested documents are nested fields, and arrays are repeated fields.
Use schema_filter with the Mongo database name. A real Mongo database name does not match the catalog database, so database_filter is ineffective for this purpose.
Source options
Metadata pipelines accept only the customer-facing source.options keys below.
service_type
Yes
all
Must be mongodb.
schema_filter
No
metadata, profiler, classification
Restrict by Mongo database name (the catalog schema level). Object with includes / excludes arrays of regex patterns.
table_filter
No
metadata, profiler, classification
Restrict by collection name. Same shape as schema_filter.
database_filter
No
Not applicable
Not useful on MongoDB. The catalog database is always default; names like appdb match nothing.
threads
No
profiler
Parallel worker count for the profiler. Raise it to cut runtime on large scopes.
Required permissions
Metadata extraction needs read access to the databases and collections in scope, plus the ability to enumerate the deployment:
readon each database in scope (orreadAnyDatabase) is required for inventory, profiling, and classification, all of which sample documents.clusterMonitoronadminlets Nilus list databases and read deployment topology.
Example grant for a dedicated metadata user:
To limit scope to specific databases, replace readAnyDatabase with a per-database read grant for each database in scope. clusterMonitor is still required so Nilus can enumerate databases.
Sample Nilus config
Depot-backed (recommended for production)
Direct URI (no depot)
Project credentials through spec.use.projection:
shallow mode runs the metadata stage only; deep mode additionally runs profiler and classification. Lineage and usage stages are never generated for MongoDB. For more ready-to-edit examples, see Metadata sample configs.
Behavior and capabilities
Connection: Use a MongoDB depot (
dataos://<depot>?purpose=rw) or a directmongodb://...URI with projected credentials. Becausespec.typeismetadata, Nilus adds the internalmetadata+routing prefix automatically. The URI accepts a comma-separated list of replica-set members in the host position. PassdatabaseNameandsslmodeas query parameters.sslmodedefaults todisablewhen omitted. Depot connections, and URIs withoutdatabaseName, still land under thedefaultcatalog database.Filter on schema, not database: A
database_filtermatching a real Mongo database name leaves inventory unchanged. It can also makeclassificationandprofilercomplete with no work. Useschema_filterwith the Mongo database name.Schema inference: MongoDB is schema-less, so field structure is inferred from a sample of documents per collection. Fields that appear only in unsampled documents may not be captured. Heterogeneous collections are represented by the shape observed in the sample.
Nested data: Nested documents and arrays are preserved as nested and repeated field structures in the catalog.
No lineage or usage: MongoDB exposes no query history or view definitions, so lineage and usage are not produced. Model relationships downstream if needed. Do not expect column-level lineage for document collections.
Scope discipline: Set
schema_filterandtable_filterin production. Exclude theadmin,local,config, andsystem.*namespaces.
Troubleshooting
Authentication failed
Wrong credentials or missing read on the target database.
Verify the projected secret and grant read (or readAnyDatabase).
not authorized on admin to execute command { listDatabases }
The user lacks clusterMonitor.
Grant clusterMonitor on admin so Nilus can enumerate databases.
Collections appear with missing fields
The document sample did not include documents carrying those fields.
Expected for heterogeneous collections; increase the sample where supported, or accept the inferred shape.
classification / profiler completed with no tags or stats
database_filter named a Mongo database.
Use schema_filter with that name instead.
Lineage / usage empty
Not supported for MongoDB.
Expected. MongoDB has no query-history or view surface. Use metadata + profiler + classification.
TLS handshake errors
Server enforces TLS but the URI omits sslmode.
Add ?sslmode=require (or a stricter mode) to the URI.
Related Docs
MongoDB: batch row movement out of MongoDB.
MongoDB: log-based change capture.
Metadata sources: all metadata-capable sources and how to scope extraction.
Metadata pipelines: the conceptual model.
Metadata pipeline config: the
spec.type: metadatacontract and DAG anatomy.Metadata sample configs: ready-to-edit YAML.
Last updated
Was this helpful?