# Kafka Connect

Lenses integrates with Kafka Connect Clusters to manage connectors.

{% hint style="warning" %}
The name of a Kafka Connect *Connections* may only contain alphanumeric characters (**\[A-Za-z0-9]**) and dashes (**-**). Valid examples would be **dev, Prod1, SQLCluster,Prod-1, SQL-Team-Awesome**.

Multiple Kafka Connect clusters are supported.

If you are using Kafka Connect < 2.6 set the following to ensure you can see Connectors

**lenses.features.connectors.topics.via.api.enabled=false**
{% endhint %}

{% hint style="success" %}
Consider [Rate Limiting](https://docs.lenses.io/latest/deployment/configuration/agent/rate-limiting) if you have a high number of connectors.

See [JSON schema](https://docs.lenses.io/latest/deployment/configuration/overview#json-schema-support) for support.

Environment variables are supported; escape the dollar sign

```yaml
sslKeystorePassword:
  value: "\${ENV_VAR_NAME}"
```

{% endhint %}

{% hint style="danger" %}
Names must match be alphanumeric or dash non-empty string.
{% endhint %}

## Simple configuration, with JMX metrics <a href="#simple-configuration-with-jmx-metrics" id="simple-configuration-with-jmx-metrics"></a>

The URLs (workers) should always have **a scheme** defined (http\:// or https\://).

{% code title="provisioning.yaml" %}

```yaml
connect:
  - name: my-connect-cluster-name
    version: 1    
    tags: ["tag1"]
    configuration:
      workers:
        value:
          - http://my-kc.worker1:8083
          - http://my-kc.worker2:8083
      metricsPort: 
        value: 9585
      metricsType: 
        value: JMX              
```

{% endcode %}

## Basic authentication <a href="#basic-authentication" id="basic-authentication"></a>

For Basic Authentication, define `username` and `password` properties.

{% code title="provisioning.yaml" %}

```yaml
connect:
  - name: my-connect-cluster-name
    tags: ["tag1"]
    version: 1      
    configuration:
      workers:
        value:
          - http://my-kc.worker1:8083
          - http://my-kc.worker2:8083    
      username: 
        value: my-username
      password: 
        value: my-password
```

{% endcode %}

## TLS with custom truststore <a href="#tls-with-custom-truststore" id="tls-with-custom-truststore"></a>

A custom truststore is needed when the Kafka Connect workers are served over TLS (encryption-in-transit) and their certificates are not signed by a trusted CA.

{% code title="provisioning.yaml" %}

```yaml
connect:
  - name: my-connect-cluster-name
    tags: ["tag1"]
    version: 1      
    configuration:
      workers:
        value:
          - http://my-kc.worker1:8083
          - http://my-kc.worker2:8083    
      sslTruststore:
        file: /connect-truststore.jks
      sslTruststorePassword: 
        value: myPassword
```

{% endcode %}

## TLS with client authentication <a href="#tls-with-client-authentication" id="tls-with-client-authentication"></a>

A custom truststore might be necessary too (see above).

{% code title="provisioning.yaml" %}

```yaml
connect:
  name: my-connect-cluster-name
  tags: ["tag1"]
  version: 1    
  configuration:
    workers:
      value:
        - http://my-kc.worker1:8083
        - http://my-kc.worker2:8083    
    sslKeystore:
      file: connect-keystore.jks
    sslKeystorePassword: 
      value: myPassword
```

{% endcode %}

## Adding 3rd Party Connector to the Topology

If you have developed your own Connector or are using not using a Lenses connector you can still display the connector instances in the topology. To do this Lenses needs to know the configuration option of the Connector that defines which topic the Connector reads from or writes to. This is set in the `connectors.info` parameter in the `lenses.conf` file.

{% code title="lenses.conf" fullWidth="false" %}

```json
connectors.info = [
      {
           class.name = "The connector full classpath"
           name = "The name which will be presented in the UI"
           instance = "Details about the instance. Contains the connector configuration field which holds the information. If  a database is involved it would be  the DB connection details, if it is a file it would be the file path, etc"
           sink = true
           extractor.class = "The full classpath for the implementation knowing how to extract the Kafka topics involved. This is only required for a Source"
           icon = "file.png"
           description = "A description for the connector"
           author = "The connector author"
      }

  ]
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/deployment/configuration/agent/automation/kafka-connect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
