Browse by type
Kafka Connect Elasticsearch Source: fetch data from elastic-search and sends it to kafka. The connector fetches only new data using a strictly incremental / temporal field (like a timestamp or an incrementing id). It supports dynamic schema and nested objects/ arrays.
The connector uses kafka-connect schema and structs, that are agnostic regarding the user serialization method (e.g. it might be Avro or json, etc...).
Compile the project with:
mvn clean package -DskipTests
You can also compile and running both unit and integration tests (docker is mandatory) with:
mvn clean package
Copy the jar with dependencies from the target folder into connect classpath (
e.g /usr/share/java/kafka-connect-elasticsearch ) or set plugin.path parameter appropriately.
Using kafka connect in distributed way, a sample config file to fetch my_awesome_index* indices and to produce
output topics with es_ prefix:
{
"name": "elastic-source",
"config": {
"connector.class":"com.github.dariobalinzo.ElasticSourceConnector",
"tasks.max": "1",
"es.host" : "localhost",
"es.port" : "9200",
"index.prefix" : "my_awesome_index",
"topic.prefix" : "es_",
"incrementing.field.name" : "@timestamp"
}
}
To start the connector with curl:
curl -X POST -H "Content-Type: application/json" --data @config.json http://localhost:8083/connectors | jq
```
To check the status:
```bash
curl localhost:8083/connectors/elastic-source/status | jq
```
To stop the connector:
```bash
curl -X DELETE localhost:8083/connectors/elastic-source | jq
es.host
ElasticSearch host. Optionally it is possible to specify many hosts using ; as separator (host1;host2;host3)
index.prefixes.port
ElasticSearch port
index.prefixes.scheme
ElasticSearch scheme (http/https)
httpes.user
Elasticsearch username
es.password
Elasticsearch password
incrementing.field.name
The name of the strictly incrementing field to use to detect new records.
incrementing.secondary.field.name
In case the main incrementing field may have duplicates,
this secondary field is used as a secondary sort field in order
to avoid data losses when paginating (available starting from versions >= 1.4).
es.tls.truststore.location
Elastic ssl truststore location
es.tls.truststore.password
Elastic ssl truststore password
es.tls.keystore.location
Elasticsearch keystore location
es.tls.keystore.password
Elasticsearch keystore password
connection.attempts
Maximum number of attempts to retrieve a valid Elasticsearch connection.
connection.backoff.ms
Backoff time in milliseconds between connection attempts.
index.prefix
Indices prefix to include in copying.
Periodically, new indices are discovered if they match the pattern.
index.names
List of elasticsearch indices: es1,es2,es3
poll.interval.ms
Frequency in ms to poll for new data in each index.
batch.max.rows
Maximum number of documents to include in a single batch when polling for new data.
topic.prefix
Prefix to prepend to index names to generate the name of the Kafka topic to publish data
filters.whitelist
Whitelist filter for extracting a subset of fields from elastic-search json documents. The whitelist filter supports
nested fields. To provide multiple fields use ; as separator
(e.g. customer;order.qty;order.price).
filters.blacklist
Blacklist filter for extracting a subset of fields from elastic-search json documents. The blacklist filter supports
nested fields. To provide multiple fields use ; as separator
(e.g. customer;order.qty;order.price).
filters.json_cast
This filter casts nested fields to json string, avoiding parsing recursively as kafka connect-schema. The json-cast
filter supports nested fields. To provide multiple fields use ; as separator
(e.g. customer;order.qty;order.price).
fieldname_converter
Configuring which field name converter should be used (allowed values: avro or nop). By default, the avro field name
converter renames the json fields non respecting the avro
specifications (https://avro.apache.org/docs/current/spec.html#names)
in order to be serialized correctly. To disable the field name conversion set this parameter to nop.
$ claude mcp add kafka-connect-elasticsearch-source \
-- python -m otcore.mcp_server <graph>