> ## 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 NATS JetStream Connector Externally

> Use YAML to configure NATS JetStream metadata ingestion. Ingest JetStream streams as topics, fetch sample data, and read schemas from a KV bucket.

![NATS JetStream](https://docs.open-metadata.org/public/images/connectors/nats.png)

# NATS JetStream

BETA

This section covers how to use the NATS JetStream connector.
Configure and run the NATS JetStream metadata workflow externally:

* [Requirements](#requirements)
* [Metadata Ingestion](#metadata-ingestion)

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

> [card] [External Schedulers](https://docs.open-metadata.org/v2.1.x/deployment/ingestion.md)
>
> Get more information about running the Ingestion Framework Externally

## Requirements

The connector communicates with the NATS JetStream API, so JetStream must be enabled on your NATS server. The credentials you supply must be allowed to publish to and receive replies from the `$JS.API.>` subjects. Schema ingestion additionally requires access to the key-value (KV) stream subjects that back the configured Schema KV bucket.

### Python Requirements

Use Python 3.10 or later. Python 3.12 is recommended, because it is what the OpenMetadata 2.0 ingestion images use. To confirm the supported range for your release, check the `Requires-Python` metadata of that release’s `openmetadata-ingestion` package.

To run the NATS JetStream ingestion, install:

```bash theme={null}
pip3 install "openmetadata-ingestion[nats]"
```

## Metadata Ingestion

All connectors are defined as JSON Schemas.
See the [NATS connection JSON Schema](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/messaging/natsConnection.json) for the structure of a NATS connection.
To create and run a metadata ingestion workflow, follow these steps to build a YAML configuration that connects to the source, processes the entities if needed, and reaches 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 NATS:

#### Source Configuration

Configure the source type and service name. `type` is `nats` and the service connection `type` is `Nats`.

#### natsServers

**natsServers**: NATS server URLs as comma-separated values. Each entry uses the `nats://host:port` form (the default NATS port is `4222`).
Example: `nats://host1:4222,nats://host2:4222`. This is the only required field.

#### authType

**authType**: The authentication method. Omit this block entirely for anonymous access. Otherwise provide exactly one of:

* **Username and Password**: `username` and `password`.
* **Token**: A single `token`.
* **NKey Seed**: An `nkeySeed` (the account seed, which begins with `S`).

#### schemaKvBucket

**schemaKvBucket**: Name of the JetStream KV bucket where schemas are stored. Keys must match stream (topic) names and values should be Avro JSON, Protobuf (`.proto`), or JSON Schema text. Leave unset to skip schema ingestion.

#### additionalConfig

**additionalConfig**: Additional NATS client configuration options passed through to the client. See the [NATS Python client documentation](https://nats-io.github.io/nats.py/). The following connection-managed keys are reserved and can't be set here: `servers`, `user`, `password`, `token`, `nkeys_seed`, `nkeys_seed_str`, `tls`, `user_credentials`, `signature_cb`, and `user_jwt_cb`.

#### tlsConfig

**tlsConfig**: Transport Layer Security (TLS) and Secure Sockets Layer (SSL) configuration for secure connections. Provide `caCertificate` to validate the server. For mutual TLS, also provide `sslCertificate` (client certificate) and `sslKey` (its private key). Both must be set together.

#### topicFilterPattern

**topicFilterPattern**: Regex that limits ingestion to streams matching the pattern. Use `includes` and/or `excludes`.

#### supportsMetadataExtraction

**supportsMetadataExtraction**: Set `supportsMetadataExtraction` to `true` or `false`.

#### Source Config

#### 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/messagingServiceMetadataPipeline.json):

* **generateSampleData**: Option to turn on or off generating sample data during metadata extraction. It supports boolean values either `true` or `false`.
* **topicFilterPattern**: Note that the `topicFilterPattern` supports regex as include or exclude.
* **markDeletedTopics**: Optional configuration to soft delete topics in OpenMetadata if the source topics are deleted. Also, if the topic is deleted, all the associated entities like sample data, lineage, etc., with that topic will be deleted. It supports boolean values either `true` or `false`.
* **overrideMetadata**: 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. It supports boolean values either `true` or `false`.

#### Sink Configuration

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

#### Workflow Configuration

The main property here is `openMetadataServerConfig`, where you can define the host and security provider of your OpenMetadata installation.

* **loggerLevel**: Specify the logger level depending on your needs. If you are troubleshooting an ingestion, use `DEBUG` for more detailed traces.
* **JWT token**: JWT tokens allow clients to authenticate against the OpenMetadata server. See [Enable JWT Tokens](https://docs.open-metadata.org/deployment/security/enable-jwt-tokens) and [JWT Troubleshooting](https://docs.open-metadata.org/deployment/security/jwt-troubleshooting) for more information.
* **storeServiceConnection**: If set to `true` (default), sensitive information is stored encrypted with the Fernet Key or externally if you have configured a [Secrets Manager](https://docs.open-metadata.org/deployment/secrets-manager). If set to `false`, the service is created, but the service connection information is only used by the Ingestion Framework at runtime and is not sent to the OpenMetadata server.
* **SSL configuration**: If you have added SSL to the [OpenMetadata server](https://docs.open-metadata.org/deployment/security/enable-ssl), configure the certificates for ingestion. Set `verifySSL` to `ignore`, or set it to `validate` and provide `sslConfig.caCertificate` with a local path to the server certificate. See [SSL Troubleshooting](https://docs.open-metadata.org/deployment/security/enable-ssl/ssl-troubleshooting) for more information.
* **ingestionPipelineFQN**: Fully qualified name of the ingestion pipeline, used to identify the current ingestion pipeline.

nats\_config.yaml
Copy full code

```yaml theme={null}
source:
  type: nats
  serviceName: local_nats
  serviceConnection:
    config:
      type: Nats
      natsServers: nats://localhost:4222  # comma-separated for multiple servers
      # Basic auth (username and password). Omit authType entirely for anonymous access.
      authType:
        username: <username>
        password: <password>
      # Token auth:
      # authType:
      #   token: <token>
      # NKey auth:
      # authType:
      #   nkeySeed: <nkey_seed>
      # schemaKvBucket: <kv_bucket_name>  # uncomment to enable schema ingestion
      additionalConfig: {}
      # TLS / mTLS configuration:
      # tlsConfig:
      #   caCertificate: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
      #   sslCertificate: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
      #   sslKey: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
      # topicFilterPattern:
      #   includes:
      #     - "^orders.*"
      # supportsMetadataExtraction: true
```

```yaml theme={null}
  sourceConfig:
    config:
      type: MessagingMetadata
      topicFilterPattern:
        excludes:
          - _confluent.*
      # includes:
      #   - topic1
      # generateSampleData: true
      # generateSampleData: false # true
      # markDeletedTopics: true # false
      # overrideMetadata:  false # true

```

```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"
```

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.