--- title: Run the MongoDB Connector Externally slug: /connectors/database/mongodb/yaml --- {% connectorDetailsHeader name="MongoDB" stage="PROD" platform="OpenMetadata" availableFeatures=["Metadata", "Data Profiler", "Sample Data"] unavailableFeatures=["Query Usage", "Data Quality", "dbt", "Owners", "Lineage", "Column-level Lineage", "Tags", "Stored Procedures"] / %} In this section, we provide guides and references to use the MongoDB connector. Configure and schedule MongoDB metadata workflows from the OpenMetadata UI: - [Requirements](#requirements) - [Metadata Ingestion](#metadata-ingestion) - [Data Profiler](#data-profiler) {% partial file="/v1.7/connectors/ingestion-modes-tiles.md" variables={yamlPath: "/connectors/database/mongodb/yaml"} /%} {% partial file="/v1.7/connectors/external-ingestion-deployment.md" /%} ## Requirements To fetch the metadata from MongoDB to OpenMetadata, the MongoDB user must have access to perform `find` operation on collection and `listCollection` operations on database available in MongoDB. ### Python Requirements {% partial file="/v1.7/connectors/python-requirements.md" /%} To run the MongoDB ingestion, you will need to install: ```bash pip3 install "openmetadata-ingestion[mongo]" ``` ## Metadata Ingestion All connectors are defined as JSON Schemas. [Here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/mongoDBConnection.json) you can find the structure to create a connection to MongoDB. In order to create and run a Metadata Ingestion workflow, we will follow the steps to create a YAML configuration able to connect to the source, process the Entities if needed, and reach the OpenMetadata server. The workflow is modeled around the following [JSON Schema](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/workflow.json) ### 1. Define the YAML Config This is a sample config for MongoDB: {% codePreview %} {% codeInfoContainer %} #### Source Configuration - Service Connection {% codeInfo srNumber=1 %} **username**: Username to connect to Mongodb. This user must have access to perform `find` operation on collection and `listCollection` operations on database available in MongoDB. {% /codeInfo %} {% codeInfo srNumber=2 %} **password**: Password to connect to MongoDB. {% /codeInfo %} {% codeInfo srNumber=3 %} **hostPort**: When using the `mongodb` connecion schema, the hostPort parameter specifies the host and port of the MongoDB. This should be specified as a string in the format `hostname:port`. E.g., `localhost:27017`. When using the `mongodb+srv` connection schema, the hostPort parameter specifies the host and port of the MongoDB. This should be specified as a string in the format `hostname`. E.g., `cluster0-abcde.mongodb.net`. Using Atlas? Follow [this guide](https://www.mongodb.com/docs/guides/atlas/connection-string/) to get the connection string. {% /codeInfo %} {% codeInfo srNumber=6 %} **databaseName**: Optional name to give to the database in OpenMetadata. If left blank, we will use default as the database name. {% /codeInfo %} {% partial file="/v1.7/connectors/yaml/database/source-config-def.md" /%} {% partial file="/v1.7/connectors/yaml/ingestion-sink-def.md" /%} {% partial file="/v1.7/connectors/yaml/workflow-config-def.md" /%} #### Advanced Configuration {% codeInfo srNumber=7 %} **Connection Options (Optional)**: Enter the details for any additional connection options that can be sent to database during the connection. These details must be added as Key-Value pairs. {% /codeInfo %} {% /codeInfoContainer %} {% codeBlock fileName="filename.yaml" %} ```yaml {% isCodeBlock=true %} source: type: mongodb serviceName: local_mongodb serviceConnection: config: type: MongoDB ``` ```yaml {% srNumber=1 %} username: username ``` ```yaml {% srNumber=2 %} password: password ``` ```yaml {% srNumber=3 %} hostPort: localhost:27017 ``` ```yaml {% srNumber=7 %} # connectionOptions: # key: value ``` ```yaml {% srNumber=6 %} databaseName: custom_database_name ``` {% partial file="/v1.7/connectors/yaml/database/source-config.md" /%} {% partial file="/v1.7/connectors/yaml/ingestion-sink.md" /%} {% partial file="/v1.7/connectors/yaml/workflow-config.md" /%} {% /codeBlock %} {% /codePreview %} {% partial file="/v1.7/connectors/yaml/ingestion-cli.md" /%} ## Data Profiler The Data Profiler workflow will be using the `orm-profiler` processor. After running a Metadata Ingestion workflow, we can run Data Profiler workflow. While the `serviceName` will be the same to that was used in Metadata Ingestion, so the ingestion bot can get the `serviceConnection` details from the server. ### Limitations The MongodDB data profiler current supports only the following features: 1. **Row count**: The number of rows in the collection. Sampling or custom query is not supported. 2. **Sample data:** If a custom query is defined it will be used for sample data. ### 1. Define the YAML Config This is a sample config for the profiler: {% codePreview %} {% codeInfoContainer %} {% codeInfo srNumber=13 %} #### Source Configuration - Source Config You can find all the definitions and types for the `sourceConfig` [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/databaseServiceProfilerPipeline.json). **generateSampleData**: Option to turn on/off generating sample data. {% /codeInfo %} {% codeInfo srNumber=16 %} **processPiiSensitive**: Optional configuration to automatically tag columns that might contain sensitive information. {% /codeInfo %} {% codeInfo srNumber=18 %} **timeoutSeconds**: Profiler Timeout in Seconds {% /codeInfo %} {% codeInfo srNumber=20 %} **schemaFilterPattern**: Regex to only fetch tables or databases that matches the pattern. {% /codeInfo %} {% codeInfo srNumber=21 %} **tableFilterPattern**: Regex to only fetch tables or databases that matches the pattern. {% /codeInfo %} {% codeInfo srNumber=22 %} #### Processor Configuration Choose the `orm-profiler`. Its config can also be updated to define tests from the YAML itself instead of the UI: **tableConfig**: `tableConfig` allows you to set up some configuration at the table level. {% /codeInfo %} {% codeInfo srNumber=23 %} #### Sink Configuration To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`. {% /codeInfo %} {% codeInfo srNumber=24 %} #### Workflow Configuration The main property here is the `openMetadataServerConfig`, where you can define the host and security provider of your OpenMetadata installation. For a simple, local installation using our docker containers, this looks like: {% /codeInfo %} {% /codeInfoContainer %} {% codeBlock fileName="filename.yaml" %} ```yaml {% isCodeBlock=true %} source: type: monogodb serviceName: local_mongodb sourceConfig: config: type: Profiler ``` ```yaml {% srNumber=13 %} generateSampleData: true ``` ```yaml {% srNumber=16 %} processPiiSensitive: false ``` ```yaml {% srNumber=18 %} # timeoutSeconds: 43200 ``` ```yaml {% srNumber=20 %} # schemaFilterPattern: # includes: # - schema1 # - schema2 # excludes: # - schema3 # - schema4 ``` ```yaml {% srNumber=21 %} # tableFilterPattern: # includes: # - table1 # - table2 # excludes: # - table3 # - table4 ``` ```yaml {% srNumber=22 %} processor: type: orm-profiler config: {} # Remove braces if adding properties # tableConfig: # - fullyQualifiedName: