> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Run the MongoDB Connector Externally

> Configure MongoDB ingestion via YAML to extract collection metadata, schema, and profiling insights from NoSQL datasets.

export const CodePanel = ({children, fileName = 'config.yaml', showLineNumbers = false}) => {
  const codePanelRef = useRef(null);
  const codeContentRef = useRef(null);
  const isProgrammaticScroll = useRef(false);
  const hoverTimeout = useRef(null);
  useEffect(() => {
    let tries = 0;
    const wrapLines = () => {
      const root = codeContentRef.current;
      if (!root) return;
      const pres = Array.from(root.querySelectorAll('pre'));
      if (!pres.length) {
        if (tries++ < 20) requestAnimationFrame(wrapLines);
        return;
      }
      let globalLine = 1;
      pres.forEach(pre => {
        const code = pre.querySelector('code') || pre;
        if (!code || code.dataset.wrapped === 'true') return;
        const raw = code.textContent || '';
        let lines = raw.split('\n');
        while (lines[0] === '') lines.shift();
        while (lines[lines.length - 1] === '') lines.pop();
        code.innerHTML = lines.map(line => {
          const ln = globalLine++;
          const num = showLineNumbers ? `<span class="line-number">${ln}</span>` : '';
          const safe = line.replace(/</g, '&lt;').replace(/>/g, '&gt;') || ' ';
          return `<span class="code-line" data-line="${ln}">${num}${safe}</span>`;
        }).join('');
        code.dataset.wrapped = 'true';
      });
    };
    wrapLines();
  }, [children, showLineNumbers]);
  useEffect(() => {
    const panel = codePanelRef.current;
    const content = codeContentRef.current;
    if (!panel || !content) return;
    const waitForLines = () => {
      const codeLines = content.querySelectorAll('.code-line');
      if (!codeLines.length) {
        requestAnimationFrame(waitForLines);
        return;
      }
      setupHighlighting(codeLines);
    };
    const setupHighlighting = codeLines => {
      const layout = panel.closest('.split-layout');
      const sections = layout.querySelectorAll('.content-section');
      const parseLines = str => {
        if (!str) return [];
        const out = [];
        str.split(',').forEach(p => {
          if (p.includes('-')) {
            const [s, e] = p.split('-').map(Number);
            for (let i = s; i <= e; i++) out.push(i);
          } else {
            const n = Number(p);
            if (!isNaN(n)) out.push(n);
          }
        });
        return out;
      };
      const clearHighlight = () => {
        codeLines.forEach(l => l.classList.remove('highlighted'));
      };
      const highlight = lines => {
        clearHighlight();
        lines.forEach(n => {
          const el = content.querySelector(`.code-line[data-line="${n}"]`);
          if (el) el.classList.add('highlighted');
        });
      };
      const scrollToLines = lines => {
        if (!lines.length) return;
        const first = lines[0];
        const targetLine = lines.length > 1 ? first : lines[0];
        const el = content.querySelector(`.code-line[data-line="${targetLine}"]`);
        if (!el) return;
        isProgrammaticScroll.current = true;
        const containerRect = content.getBoundingClientRect();
        const elRect = el.getBoundingClientRect();
        const offset = elRect.top - containerRect.top + content.scrollTop;
        const TOP_PADDING = 16;
        content.scrollTo({
          top: Math.max(offset - TOP_PADDING, 0),
          behavior: 'smooth'
        });
        setTimeout(() => {
          isProgrammaticScroll.current = false;
        }, 200);
      };
      const activate = (section, scroll) => {
        if (section.classList.contains('active')) return;
        sections.forEach(s => s.classList.remove('active'));
        section.classList.add('active');
        const lines = parseLines(section.dataset.lines);
        highlight(lines);
        if (scroll) scrollToLines(lines);
      };
      const observer = new IntersectionObserver(entries => {
        if (isProgrammaticScroll.current) return;
        entries.forEach(e => {
          if (e.isIntersecting) activate(e.target, false);
        });
      }, {
        threshold: 0.3,
        rootMargin: '-80px 0px -40% 0px'
      });
      sections.forEach(section => {
        observer.observe(section);
        section.addEventListener('click', () => activate(section, true));
        section.addEventListener('mouseenter', () => {
          clearTimeout(hoverTimeout.current);
          hoverTimeout.current = setTimeout(() => activate(section, true), 80);
        });
      });
      if (sections[0]) activate(sections[0], false);
    };
    waitForLines();
  }, []);
  const handleCopy = e => {
    const btn = e.currentTarget;
    const codeLines = codeContentRef.current?.querySelectorAll('.code-line');
    if (!codeLines || codeLines.length === 0) return;
    const text = Array.from(codeLines).map(line => {
      const clone = line.cloneNode(true);
      const lineNumber = clone.querySelector('.line-number');
      if (lineNumber) lineNumber.remove();
      return clone.textContent;
    }).join('\n');
    if (!text) return;
    navigator.clipboard.writeText(text).then(() => {
      btn.dataset.copied = 'true';
      setTimeout(() => btn.dataset.copied = 'false', 1500);
    });
  };
  return <div className="code-panel" ref={codePanelRef}>
      <div className="code-header">
        {fileName}
        <button className="copy-btn" aria-label="Copy full code" data-copied="false" onClick={handleCopy}>
          <svg className="icon-copy" viewBox="0 0 15 16" fill="currentColor">
            <path d="M10.113 3.124H2.205C1.463 3.124.86 3.655.86 4.31v10.005c0 .654.603 1.186 1.345 1.186h7.908c.742 0 1.345-.532 1.345-1.186V4.31c0-.655-.606-1.186-1.345-1.186Z" />
            <path d="M13.138.5H5.229c-.742 0-1.344.531-1.344 1.186 0 .23.209.414.47.414s.47-.184.47-.414c0-.197.182-.357.404-.357h7.909c.223 0 .404.16.404.357V11.69c0 .196-.181.356-.404.356-.262 0-.47.184-.47.415 0 .23.208.415.47.415.742 0 1.344-.532 1.344-1.186V1.686C14.482 1.03 13.88.5 13.138.5Z" />
          </svg>

          <svg className="icon-check" viewBox="0 0 20 20" fill="currentColor">
            <path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-7.25 7.25a1 1 0 01-1.414 0l-3.25-3.25a1 1 0 011.414-1.414l2.543 2.543 6.543-6.543a1 1 0 011.414 0z" clipRule="evenodd" />
          </svg>
        </button>
      </div>

      <div className="code-content" ref={codeContentRef}>
        {children}
      </div>
    </div>;
};

export const ContentSection = ({id, title, lines, children}) => <div className="content-section" data-content-id={id} data-lines={lines}>
    {title && <h4>{title}</h4>}
    {children}
  </div>;

export const ContentPanel = ({children}) => <div className="content-panel">{children}</div>;

export const CodePreview = ({children}) => {
  const [instanceId] = useState(() => `preview-${Math.random().toString(36).slice(2)}`);
  useEffect(() => {
    const nav = document.querySelector('nav') || document.querySelector('header') || document.querySelector('[class*="nav"]');
    if (nav) {
      document.documentElement.style.setProperty('--navbar-height', `${nav.offsetHeight}px`);
    }
  }, []);
  return <div className="split-layout" data-preview-id={instanceId}>
      {children}
    </div>;
};

export const ConnectorDetailsHeader = ({name, icon, stage, availableFeatures, unavailableFeatures = [], availableFeaturesCollate = []}) => {
  const showSubHeading = availableFeatures?.length > 0 || unavailableFeatures?.length > 0 || availableFeaturesCollate?.length > 0;
  const totalAvailableFeatures = [...availableFeatures || [], ...availableFeaturesCollate || []];
  return <div className="container">
      <div className="Heading">
        <div className="flex items-center gap-3">
          {icon && <div className="IconContainer">
              <img src={icon} alt={name} noZoom className="ConnectorIcon" />
            </div>}
          <h1 className="ConnectorName">{name}</h1>
          <span className={`StageBadge ${stage === 'PROD' ? 'prod' : 'beta'}`}>
            {stage}
          </span>
        </div>
      </div>
      {showSubHeading && <div className="SubHeading">
          <div className="FeaturesHeading">Feature List</div>
          <div className="FeaturesList">
            {totalAvailableFeatures.map(feature => <div className="FeatureTag AvailableFeature" key={feature}>
                ✓ {feature}
              </div>)}
            {unavailableFeatures.map(feature => <div className="FeatureTag UnavailableFeature" key={feature}>
                ✕ {feature}
              </div>)}
          </div>
        </div>}
    </div>;
};

<ConnectorDetailsHeader icon="/public/images/connectors/mongodb.webp" name="MongoDB" stage="PROD" availableFeatures={["Metadata", "Data Profiler", "Sample Data", "Auto-Classification"]} 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)

## How to Run the Connector Externally

To run the Ingestion via the UI you'll need to use the OpenMetadata Ingestion Container, which comes shipped with
custom Airflow plugins to handle the workflow deployment.

If, instead, you want to manage your workflows externally on your preferred orchestrator, you can check
the following docs to run the Ingestion Framework **anywhere**.

<Columns cols={2}>
  <Card title="External Schedulers" href="/v1.12.x/deployment/ingestion">
    Get more information about running the Ingestion Framework Externally
  </Card>
</Columns>

## 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

<Tip>
  We have support for Python versions **3.9-3.11**
</Tip>

To run the MongoDB ingestion, you will need to install:

```bash theme={null}
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>
  <ContentPanel>
    <ContentSection id={1} title="Source Configuration" lines="1-3">
      Configure the source type and service name for your MongoDB connector.
    </ContentSection>

    <ContentSection id={2} title="Username" lines="7">
      **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.
    </ContentSection>

    <ContentSection id={3} title="Password" lines="8">
      **password**: Password to connect to MongoDB.
    </ContentSection>

    <ContentSection id={4} title="Host Port" lines="9">
      **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.
    </ContentSection>

    <ContentSection id={5} title="Database Name" lines="12">
      **databaseName**: Optional name to give to the database in OpenMetadata. If left blank, we will use default as the database name.
    </ContentSection>

    <ContentSection id={6} title="Connection Options" lines="13-56">
      #### Advanced Configuration

      **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.
    </ContentSection>

    <ContentSection id={7} title="Source Config" lines="13-56">
      #### Source Configuration - Source Config

      The `sourceConfig` is defined [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/databaseServiceMetadataPipeline.json):

      <div>
        **markDeletedTables**: To flag tables as soft-deleted if they are not present anymore in the source system.
      </div>

      <div>
        **markDeletedStoredProcedures**: Optional configuration to soft delete stored procedures in OpenMetadata if the source stored procedures are deleted. Also, if the stored procedures is deleted, all the associated entities like lineage, etc., with that stored procedures will be deleted.

        **markDeletedSchemas**: Optional configuration to soft delete schemas stored in OpenMetadata if the source schema is deleted. Setting this flag to true will only keep filtered schema and delete any other schemas that do not match schemaFilterPattern or do not exist at source.

        **markDeletedDatabases**: Additional optional configuration for soft deletion, providing granular option to select which particular entities should be deleted.

        **includeTables**: true or false, to ingest table data. Default is true.
      </div>

      <div>
        **includeViews**: true or false, to ingest views definitions.
      </div>

      <div>
        **includeTags**: Optional configuration to toggle the tags ingestion.
      </div>

      <div>
        **includeOwners**: Set the 'Include Owners' toggle to control whether to include owners to the ingested entity if the owner email matches with a user stored in the OM server as part of metadata ingestion. If the ingested entity already exists and has an owner, the owner will not be overwritten.
      </div>

      <div>
        **includeStoredProcedures**: Optional configuration to toggle the Stored Procedures ingestion.
      </div>

      <div>
        **includeDDL**: Optional configuration to toggle the DDL Statements ingestion.
      </div>

      <div>
        **overrideMetadata** *(boolean)*: Set the 'Override Metadata' toggle to control whether to override the existing metadata in the OpenMetadata server with the metadata fetched from the source. If the toggle is set to true, the metadata fetched from the source will override the existing metadata in the OpenMetadata server. If the toggle is set to false, the metadata fetched from the source will not override the existing metadata in the OpenMetadata server. This is applicable for fields like description, tags, owner and displayName.
      </div>

      <div>
        **queryLogDuration**: Configuration to tune how far we want to look back in query logs to process Stored Procedures results.
      </div>

      <div>
        **queryParsingTimeoutLimit**: Configuration to set the timeout for parsing the query in seconds.
      </div>

      <div>
        **useFqnForFiltering**: Regex will be applied on fully qualified name (e.g service\_name.db\_name.schema\_name.table\_name) instead of raw name (e.g. table\_name).
      </div>

      <div>
        **databaseFilterPattern**, **schemaFilterPattern**: Note that the filter supports regex as include or exclude. You can find examples [here](/connectors/ingestion/workflows/metadata/filter-patterns/database)
      </div>

      <div>
        **tableFilterPattern**: Note that the filter supports regex as include or exclude. You can find examples [here](/connectors/ingestion/workflows/metadata/filter-patterns/table)
      </div>

      <div>
        **threads (beta)**: The number of threads to use when extracting the metadata using multithreading.
      </div>

      <div>
        **databaseMetadataConfigType** *(string)*: Database Source Config Metadata Pipeline type.
      </div>

      <div>
        **incremental (beta)**: Incremental Extraction configuration. Currently implemented for:

        * [BigQuery](/connectors/ingestion/workflows/metadata/incremental-extraction/bigquery)
        * [Redshift](/connectors/ingestion/workflows/metadata/incremental-extraction/redshift)
        * [Snowflake](/connectors/ingestion/workflows/metadata/incremental-extraction/snowflake)
      </div>
    </ContentSection>

    <ContentSection id={8} title="Sink Configuration" lines="57-59">
      To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.
    </ContentSection>

    <ContentSection id={9} title="Workflow Configuration" lines="60-76">
      <div>
        The main property here is the `openMetadataServerConfig`, where you can define the host and security provider of your OpenMetadata installation.
      </div>

      <div>
        **Logger Level**

        You can specify the `loggerLevel` depending on your needs. If you are trying to troubleshoot an ingestion, running with `DEBUG` will give you far more traces for identifying issues.
      </div>

      <div>
        **JWT Token**

        JWT tokens will allow your clients to authenticate against the OpenMetadata server. To enable JWT Tokens, you will get more details [here](/deployment/security/enable-jwt-tokens).

        You can refer to the JWT Troubleshooting section [link](/deployment/security/jwt-troubleshooting) for any issues in your JWT configuration.
      </div>

      <div>
        **Store Service Connection**

        If set to `true` (default), we will store the sensitive information either encrypted via the Fernet Key in the database or externally, if you have configured any [Secrets Manager](/deployment/secrets-manager).

        If set to `false`, the service will be created, but the service connection information will only be used by the Ingestion Framework at runtime, and won't be sent to the OpenMetadata server.
      </div>

      <div>
        **SSL Configuration**

        If you have added SSL to the [OpenMetadata server](/deployment/security/enable-ssl), then you will need to handle the certificates when running the ingestion too. You can either set `verifySSL` to `ignore`, or have it as `validate`, which will require you to set the `sslConfig.caCertificate` with a local path where your ingestion runs that points to the server certificate file.

        Find more information on how to troubleshoot SSL issues [here](/deployment/security/enable-ssl/ssl-troubleshooting).
      </div>

      <div>
        **ingestionPipelineFQN**

        Fully qualified name of ingestion pipeline, used to identify the current ingestion pipeline.
      </div>
    </ContentSection>
  </ContentPanel>

  <CodePanel fileName="mongodb_config.yaml">
    ```yaml theme={null}
    source:
      type: mongodb
      serviceName: local_mongodb
      serviceConnection:
        config:
          type: MongoDB
          username: username
          password: password
          hostPort: localhost:27017
          # connectionOptions:
          #   key: value
          databaseName: custom_database_name
    ```

    ```yaml theme={null}
      sourceConfig:
        config:
          type: DatabaseMetadata
          markDeletedTables: true
          markDeletedStoredProcedures: true
          markDeletedSchemas: true
          markDeletedDatabases: true
          includeTables: true
          includeViews: true
          # includeTags: true
          # includeOwners: false
          # includeStoredProcedures: true
          # includeDDL: true
          # overrideMetadata: false
          # queryLogDuration: 1
          # queryParsingTimeoutLimit: 300
          # useFqnForFiltering: false
          # threads: 1
          # databaseMetadataConfigType: ()
          # incremental:
          #   enabled: true
          #   lookbackDays: 7
          #   safetyMarginDays: 1
          # databaseFilterPattern:
          #   includes:
          #     - database1
          #     - database2
          #   excludes:
          #     - database3
          #     - database4
          # schemaFilterPattern:
          #   includes:
          #     - schema1
          #     - schema2
          #   excludes:
          #     - schema3
          #     - schema4
          # tableFilterPattern:
          #   includes:
          #     - users
          #     - type_test
          #   excludes:
          #     - table3
          #     - table4
    ```

    ```yaml theme={null}
    sink:
      type: metadata-rest
      config: {}
    ```

    ```yaml theme={null}
    workflowConfig:
      loggerLevel: INFO  # DEBUG, INFO, WARNING or ERROR
      openMetadataServerConfig:
        hostPort: "http://localhost:8585/api"
        authProvider: openmetadata
        securityConfig:
          jwtToken: "{bot_jwt_token}"
        ## Store the service Connection information
        storeServiceConnection: true  # false
        ## Secrets Manager Configuration
        # secretsManagerProvider: aws, azure or noop
        # secretsManagerLoader: airflow or env
        ## If SSL, fill the following
        # verifySSL: validate  # or ignore
        # sslConfig:
        #   caCertificate: /local/path/to/certificate
    # ingestionPipelineFQN: <service name>.<ingestion name> ## e.g., "my_redshift.metadata"
    ```
  </CodePanel>
</CodePreview>

### 2. Run with the CLI

First, we will need to save the YAML file. Afterward, and with all requirements installed, we can run:

```bash theme={null}
metadata ingest -c <path-to-yaml>
```

Note that from connector to connector, this recipe will always be the same. By updating the YAML configuration,
you will be able to extract metadata from different sources.

## 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>
  <ContentPanel>
    <ContentSection id={1} title="Source Configuration" lines="1-3">
      #### 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.
    </ContentSection>

    <ContentSection id={2} title="Process PII Sensitive" lines="76">
      **processPiiSensitive**: Optional configuration to automatically tag columns that might contain sensitive information.
    </ContentSection>

    <ContentSection id={3} title="Timeout Seconds" lines="76">
      **timeoutSeconds**: Profiler Timeout in Seconds
    </ContentSection>

    <ContentSection id={4} title="Schema Filter Pattern" lines="43">
      **schemaFilterPattern**: Regex to only fetch tables or databases that matches the pattern.
    </ContentSection>

    <ContentSection id={5} title="Table Filter Pattern" lines="50">
      **tableFilterPattern**: Regex to only fetch tables or databases that matches the pattern.
    </ContentSection>

    <ContentSection id={6} title="Processor Configuration" lines="76">
      #### 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.
    </ContentSection>

    <ContentSection id={7} title="Sink Configuration" lines="57-59">
      #### Sink Configuration

      To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.
    </ContentSection>

    <ContentSection id={8} title="Workflow Configuration" lines="60-76">
      #### 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:
    </ContentSection>
  </ContentPanel>

  <CodePanel fileName="mongodb_profiler_config.yaml">
    ```yaml theme={null}
    source:
      type: monogodb
      serviceName: local_mongodb
      sourceConfig:
        config:
          type: Profiler
          generateSampleData: true
          processPiiSensitive: false
          # timeoutSeconds: 43200
          # schemaFilterPattern:
          #   includes:
          #     - schema1
          #     - schema2
          #   excludes:
          #     - schema3
          #     - schema4
          # tableFilterPattern:
          #   includes:
          #     - table1
          #     - table2
          #   excludes:
          #     - table3
          #     - table4
    processor:
      type: orm-profiler
      config: {}  # Remove braces if adding properties
        # tableConfig:
        #   - fullyQualifiedName: <table fqn>
        #     profileQuery: <query to use for fetching the sample data>
    sink:
      type: metadata-rest
      config: {}
    workflowConfig:
      # loggerLevel: DEBUG  # DEBUG, INFO, WARN or ERROR
      openMetadataServerConfig:
        hostPort: <OpenMetadata host and port>
        authProvider: <OpenMetadata auth provider>
    ```
  </CodePanel>
</CodePreview>

* You can learn more about how to configure and run the Profiler Workflow to extract Profiler data and execute the Data Quality from [here](/v1.12.x/how-to-guides/data-quality-observability/profiler/profiler-workflow)

### 2. Prepare the Profiler DAG

Here, we follow a similar approach as with the metadata and usage pipelines, although we will use a different Workflow class:

<CodePreview>
  <ContentPanel>
    <ContentSection id={1} title="Import Necessary Modules" lines="76">
      #### Import necessary modules

      The `ProfilerWorkflow` class that is being imported is a part of a metadata orm\_profiler framework, which defines a process of extracting Profiler data.

      Here we are also importing all the basic requirements to parse YAMLs, handle dates and build our DAG.
    </ContentSection>

    <ContentSection id={2} title="Default Arguments" lines="76">
      **Default arguments for all tasks in the Airflow DAG.**

      * Default arguments dictionary contains default arguments for tasks in the DAG, including the owner's name, email address, number of retries, retry delay, and execution timeout.
    </ContentSection>

    <ContentSection id={3} title="Config" lines="5-12">
      * **config**: Specifies config for the profiler as we prepare above.
    </ContentSection>

    <ContentSection id={4} title="Workflow Function" lines="76">
      * **metadata\_ingestion\_workflow()**: This code defines a function `metadata_ingestion_workflow()` that loads a YAML configuration, creates a `ProfilerWorkflow` object, executes the workflow, checks its status, prints the status to the console, and stops the workflow.
    </ContentSection>

    <ContentSection id={5} title="DAG Definition" lines="76">
      * **DAG**: creates a DAG using the Airflow framework, and tune the DAG configurations to whatever fits with your requirements
      * For more Airflow DAGs creation details visit [here](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/dags.html#declaring-a-dag).
    </ContentSection>
  </ContentPanel>

  <CodePanel fileName="mongodb_profiler_dag.py">
    ```python theme={null}
    import pathlib
    import yaml
    from datetime import timedelta
    from airflow import DAG

    from metadata.profiler.api.workflow import ProfilerWorkflow

    default_args = {
        "owner": "user_name",
        "email": ["username@org.com"],
        "execution_timeout": timedelta(minutes=60),
        "retries": 3,
        "retry_delay": timedelta(minutes=5),
    }

    config = """
    <your YAML configuration>
    """

    def metadata_ingestion_workflow():
        workflow_config = yaml.safe_load(config)
        workflow = ProfilerWorkflow.create(workflow_config)
        workflow.execute()
        workflow.raise_from_status()
        workflow.print_status()
        workflow.stop()

    with DAG(
        "profiler_example",
        default_args=default_args,
        description="An example DAG which runs the ProfilerWorkflow",
        start_date=datetime(2021, 1, 1),
        is_paused_upon_creation=False,
        catchup=False,
    ) as dag:
        ingest_task = PythonOperator(
            task_id="profile_and_test_using_recipe",
            python_callable=metadata_ingestion_workflow,
        )
    ```
  </CodePanel>
</CodePreview>

## dbt Integration

<Columns cols={2}>
  <Card title="dbt Integration" href="/v1.12.x/connectors/database/dbt">
    Learn more about how to ingest dbt models
  </Card>
</Columns>
