English | 中文
A Kafka Connect sink connector that batches Kafka records into an IoTDB Table-model database through the REST Table v1 API (insertTablet).
- Groups the records of each topic into tablets of at most
iotdb.batch.sizerows and POSTs them to/rest/table/v1/insertTablet. - Maps
iotdb.columns(name:type:category) onto table columns;TAGandATTRIBUTEcolumns must beSTRINGandtimeis reserved. - Creates the database and table with
CREATE DATABASE IF NOT EXISTSandCREATE TABLE IF NOT EXISTSthrough/rest/table/v1/nonQuerywheniotdb.auto.create=true. - Retries transport failures up to
iotdb.max.retries; a server-side error fails the task instead of dropping the batch.
| 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-api3.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).
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 verifyThe build produces the shaded plugin archive target/kafka-connect-iotdb.jar; every runtime library except the Connect API is inside that archive.
mvn -B -ntp verifyThe 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.
| 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:FIELDRecords 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.
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.propertiesUpstream 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.
Apache-2.0. See LICENSE.