> ## 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 Elasticsearch Connector Externally

> Use YAML to configure Elasticsearch metadata ingestion and track index schemas, mappings, and lineage paths.

![Elasticsearch](https://docs.open-metadata.org/public/images/connectors/elasticsearch.webp)

# Elasticsearch

PROD

In this section, we provide guides and references to use the Elasticsearch connector.
Configure and schedule Elasticsearch metadata and profiler workflows from the OpenMetadata UI:

* [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

We support Elasticsearch 7.0 and above.
We extract Elasticsearch's metadata by using its [API](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html). To run this ingestion, you just need a user with permissions to the ElasticSearch instance.

### 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 Elasticsearch ingestion, you will need to install:

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

## 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/search/elasticSearchConnection.json)
you can find the structure to create a connection to ElasticSearch.
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 Elasticsearch:

#### hostPort

**hostPort**: This parameter specifies the host and port of the Elasticsearch instance. This should be specified as a URI string in the format `http://<hostname>:<port>` or `https://<hostname>:<port>`. For example, you might set it to `https://localhost:9200`.

#### Basic Authentication

**Basic Authentication**\\

**username**: Username to connect to Elasticsearch. Required when Basic Authentication is enabled.\\

**password**: Password of the user account to connect with Elasticsearch.

#### API Key Authentication

**API Key Authentication**\\

**apiKey**: API Key to connect to Elasticsearch. Required when API Key Authentication is enabled.\\

**apiKeyId**: Optional field. Enter API Key ID if there is any associated with the API Key. Can be skipped if not applicable.

#### sslConfig

**sslConfig**:\\

*1. SSL Certificates By Path*\\

* **caCertPath**: Path to the CA certificate.\\

* **clientCertPath**: Path to the client certificate.\\

* **privateKeyPath**: Path to the private key.\
  \\

*2. SSL Certificates By Value*\\

* **caCertValue**: Value of the CA certificate.\\

* **clientCertValue**: Value of the client certificate.\\

* **privateKeyValue**: Value of the private key.\\

* **stagingDir**: Temporary directory for storing certificate values during ingestion.\
  \\

**Note**: When using value-based certificates, make sure to replace new lines with `\n`. Example:\\

`-----BEGIN CERTIFICATE-----
MII..
MBQ...
CgU..
8Lt..
...
h+4= -----END CERTIFICATE-----`

should be converted to:\\

`-----BEGIN CERTIFICATE-----\nMII..\nMBQ...\nCgU..\n8Lt..\n...\nh+4=\n-----END CERTIFICATE-----\n`

#### connectionTimeoutSecs

**connectionTimeoutSecs**: Connection timeout duration (in seconds) for connecting to Elasticsearch APIs.

#### Source Config

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

* **includeSampleData**: Set the **Ingest Sample Data** toggle to control whether to ingest sample data as part of metadata ingestion.
* **sampleSize**: If include sample data is enabled, 10 records will be ingested by default. Using this field you can customize the size of sample data.
* **markDeletedSearchIndexes**: Optional configuration to soft delete `search indexes` in OpenMetadata if the source `search indexes` are deleted. After deleting, all the associated entities like lineage, etc., with that `search index` will be deleted.
* **searchIndexFilterPattern**: Note that the `searchIndexFilterPattern` supports regex to include or exclude search indexes during metadata ingestion process.
* **includeIndexTemplate**: Set the **Include Index Templates** toggle to control whether to include index templates as part of metadata ingestion.
* **overrideMetadata**: Set the **Override Metadata** toggle to control whether to override the metadata if it already exists.

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

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.

connector\_config.yaml
Copy full code

```yaml theme={null}
source:
  type: elasticsearch
  serviceName: elasticsearch_source
  serviceConnection:
    config:
      type: ElasticSearch
hostPort: http://localhost:9200  # REQUIRED - Elasticsearch cluster URL
authType:
        username: elastic  # Basic auth username
        password: my_own_password  # Basic auth password
# apiKeyId: <api key id>
        # apiKey: <api key>
sslConfig:
        certificates:
          caCertPath: /path/to/http_ca.crt
          clientCertPath: /path/to/http_ca.crt
          privateKeyPath: /path/to/http_ca.crt
          # pass certificate values
          # caCertValue: -----BEGIN CERTIFICATE-----\n....\n.....\n-----END CERTIFICATE-----\n
          # clientCertValue: -----BEGIN CERTIFICATE-----\n....\n...-----END CERTIFICATE-----\n
          # privateKeyValue: -----BEGIN RSA PRIVATE KEY-----\n....\n....\n-----END RSA PRIVATE KEY-----\n
          # stagingDir: /tmp/stage
```

```yaml theme={null}
      connectionTimeoutSecs: 30
```

```yaml theme={null}
  sourceConfig:
    config:
      type: SearchMetadata
      # markDeletedSearchIndexes: true
      # includeSampleData: false
      # sampleSize: 10
      # searchIndexFilterPattern:
      #   includes:
      #     - index1
      #     - index2
      #   excludes:
      #     - index4
      #     - index3
      # includeIndexTemplates: false
      # overrideMetadata: false
```

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