Skip to content

IoTDB Sink ​

The IoTDB sink writes data into Apache IoTDB by using the native Thrift RPC client. It supports both the tree model and the table model.

Compile the Plugin ​

In the rekuiper source code root directory, run the following command:

shell
go build -trimpath --buildmode=plugin -o plugins/sinks/Iotdb.so extensions/sinks/iotdb/*.go

Properties ​

Connection Properties ​

Property nameOptionalDefault valueDescription
addrfalse127.0.0.1:6667IoTDB server address in host:port format.
usernametruerootThe username for authentication.
passwordtruerootThe password for authentication.
nodeUrlstrue[]Cluster node URLs. When set, overrides the addr property.
timeouttrue5000Connection timeout in milliseconds.
poolSizetrue3The size of the connection pool.

Model Selection ​

Property nameOptionalDefault valueDescription
modelfalsetreeThe data model to use: tree or table.

Tree Model Properties ​

The following properties apply when model is set to tree:

Property nameOptionalDefault valueDescription
devicetrue""The device path, such as root.sg1.dev1. Required for the tree model.
isAlignedtruefalseControls whether to use aligned time series.

Table Model Properties ​

The following properties apply when model is set to table:

Property nameOptionalDefault valueDescription
databasetrue""The database name. The root. prefix is removed automatically. Required for the table model.
tabletrue""The target table name. Required for the table model.
columnCategoriestrue[]Column categories mapped one-to-one to measurements: TAG, FIELD, or ATTRIBUTE. Required for the table model.

Data Mapping Properties ​

Property nameOptionalDefault valueDescription
measurementsfalse[]List of measurement or column names.
dataTypesfalse[]IoTDB data types mapped one-to-one to measurements: INT32, INT64, FLOAT, DOUBLE, BOOLEAN, TEXT, STRING, or TIMESTAMP.
tsFieldNametrue""Field name containing the timestamp in milliseconds. If omitted, rekuiper uses the current time. When set, every record must contain this field.
batchSizetrue10The number of rows written per tablet batch.

Other common sink properties, including batch settings, are supported. Refer to sink common properties for more information.

Sample Usage ​

Tree Model Example ​

The following rule selects temperature values greater than 50 and writes data to IoTDB using the tree model:

json
{
  "id": "iotdb_tree",
  "sql": "SELECT * from demo_stream where temperature > 50",
  "actions": [
    {
      "log": {},
      "iotdb": {
        "addr": "127.0.0.1:6667",
        "username": "root",
        "password": "root",
        "model": "tree",
        "device": "root.sg1.d1",
        "measurements": ["temperature", "humidity"],
        "dataTypes": ["FLOAT", "FLOAT"],
        "tsFieldName": "ts",
        "batchSize": 10
      }
    }
  ]
}

Table Model Example ​

The following rule selects temperature values greater than 50 and writes data to IoTDB using the table model:

json
{
  "id": "iotdb_table",
  "sql": "SELECT * from demo_stream where temperature > 50",
  "actions": [
    {
      "log": {},
      "iotdb": {
        "addr": "127.0.0.1:6667",
        "username": "root",
        "password": "root",
        "model": "table",
        "database": "iot_data",
        "table": "sensor_data",
        "measurements": ["device_id", "temperature", "humidity"],
        "dataTypes": ["STRING", "FLOAT", "FLOAT"],
        "columnCategories": ["TAG", "FIELD", "FIELD"],
        "tsFieldName": "ts",
        "batchSize": 10
      }
    }
  ]
}

Data Types ​

The following IoTDB data types are supported in the dataTypes property:

Data typeDescription
INT3232-bit signed integer
INT6464-bit signed integer
FLOATSingle-precision floating point
DOUBLEDouble-precision floating point
BOOLEANBoolean value (true or false)
TEXTText string (legacy IoTDB type)
STRINGString value
TIMESTAMPTimestamp value in milliseconds

Notes ​

  • Apache IoTDB uses the Thrift RPC protocol on TCP port 6667 by default.
  • For the table model, rekuiper automatically creates the database if it does not exist.
  • The root. prefix in the database property is stripped automatically in the table model.
  • Missing record fields are written to IoTDB as null values.

Released under the Apache-2.0 / MIT License.