Skip to content

About

Kafka Connect sink writing record batches to Apache IoTDB (Table REST v1)

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Kafka Connect Sink for IoTDB

English | 中文

A Kafka Connect sink connector that batches Kafka records into an IoTDB Table-model database through the REST Table v1 API (insertTablet).

CI

What it does

  • Groups the records of each topic into tablets of at most iotdb.batch.size rows and POSTs them to /rest/table/v1/insertTablet.
  • Maps iotdb.columns (name:type:category) onto table columns; TAG and ATTRIBUTE columns must be STRING and time is reserved.
  • Creates the database and table with CREATE DATABASE IF NOT EXISTS and CREATE TABLE IF NOT EXISTS through /rest/table/v1/nonQuery when iotdb.auto.create=true.
  • Retries transport failures up to iotdb.max.retries; a server-side error fails the task instead of dropping the batch.

Compatibility

IoTDB version Data model Protocol JDK
2.x Table HTTP REST, Table v1 (/rest/table/v1/insertTablet, /rest/table/v1/nonQuery) Java 8 or newer
  • Kafka Connect API 3.7 (connect-api 3.7.0) is supplied by the worker and is not bundled in the archive.
  • Requests use HTTP Basic authentication and a per-request timeout (iotdb.timeout.ms).

Build

Prerequisites: a JDK 8 or newer and Maven 3.8 or newer. CI builds with Temurin 8.

git clone https://github.com/iotdb-ecosystem/iotdb-kafka-connect.git
cd iotdb-kafka-connect
mvn -B -ntp verify

The build produces the shaded plugin archive target/kafka-connect-iotdb.jar; every runtime library except the Connect API is inside that archive.

Test

mvn -B -ntp verify

The unit tests start a local HTTP server, so no Kafka worker and no IoTDB instance are needed; this is exactly the command CI runs. The live round-trip test IoTDBRoundTripTest runs only when IOTDB_TEST_URL, IOTDB_TEST_USER and IOTDB_TEST_PASSWORD point at an isolated server, and is skipped otherwise.

Configuration

Key Default Meaning
iotdb.url required Base URL of the IoTDB REST service
iotdb.user, iotdb.password required Basic-auth credentials
iotdb.database required Target table-model database
iotdb.table required Target table
iotdb.columns required Comma-separated name:type:category columns
iotdb.time.field ts JSON field holding the timestamp; empty uses the Kafka record timestamp
iotdb.timestamp.precision ms ms, us or ns, matching the server
iotdb.auto.create false Create the database and table when absent
iotdb.batch.size 250 Maximum rows per tablet (1-10000)
iotdb.timeout.ms 10000 Connect and read timeout per request
iotdb.max.retries 2 Retries per request after transport errors
iotdb.retry.backoff.ms 250 Delay between retries
name=iotdb-sink
connector.class=io.github.wendaoji.iotdb.IoTDBSinkConnector
tasks.max=1
topics=measurements
iotdb.url=https://localhost:18080
iotdb.user=root
iotdb.password=replace-with-secret
iotdb.database=telemetry
iotdb.table=meters
iotdb.columns=device:STRING:TAG,current:DOUBLE:FIELD

Records may be JSON text, JSON bytes, maps or Connect Struct values. Column types are STRING, TEXT, BOOLEAN, INT32, INT64, FLOAT, DOUBLE, TIMESTAMP and DATE; at least one FIELD is required.

Usage

mkdir -p /opt/kafka/plugins/iotdb
cp target/kafka-connect-iotdb.jar /opt/kafka/plugins/iotdb/
# add /opt/kafka/plugins/iotdb to plugin.path in the worker configuration, then:
connect-standalone.sh config/connect-standalone.properties config/connect-iotdb.properties

Project status

Upstream candidate. Intended for connectors/ in apache/iotdb-extras; maintainers of apache/iotdb-extras are welcome to adopt this code — open an issue and we will transfer or co-maintain it.

License

Apache-2.0. See LICENSE.

About

Kafka Connect sink writing record batches to Apache IoTDB (Table REST v1)

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages