跳到主要内容
版本:Next

InfluxDB

InfluxDB 源连接器

描述

通过 InfluxDB 读取外部数据源数据。

关键特性

支持查询 SQL 并可以实现投影效果。

选项

参数名类型必须默认值描述
urlstring-InfluxDB 连接 URL
sqlstring-用于搜索数据的查询 SQL
schemaconfig-上游数据的模式信息
databasestring-InfluxDB 数据库
usernamestring-InfluxDB 用户名
passwordstring-InfluxDB 密码
lower_boundlong-split_column 的下界
upper_boundlong-split_column 的上界
partition_numint-分区数量
split_columnstring-分割列
epochstringn返回的时间精度
connect_timeout_mslong15000连接 InfluxDB 的超时时间(毫秒)
query_timeout_secint3查询超时时间(秒)
common-optionsconfig-源插件通用参数

url

连接到 InfluxDB 的 URL,例如:

http://influxdb-host:8086

sql [string]

用于搜索数据的查询 SQL

select name,age from test

schema [config]

fields [Config]

上游数据的模式信息,例如:

schema {
fields {
name = string
age = int
}
}

database [string]

InfluxDB 数据库

username [string]

InfluxDB 用户名

password [string]

InfluxDB 密码

split_column [string]

InfluxDB 的分割列

提示:

  • InfluxDB tags 不支持作为分割主键,因为 tags 的类型只能是字符串
  • InfluxDB time 不支持作为分割主键,因为 time 字段无法参与数学计算
  • 目前,split_column 仅支持整数数据分割,不支持 floatstringdate 等类型。

upper_bound [long]

split_column 列的上界

lower_bound [long]

split_column 列的下界

     将 $split_column 范围分成 $partition_num 部分
如果 partition_num 为 1,使用整个 `split_column` 范围
如果 partition_num < (upper_bound - lower_bound),使用 (upper_bound - lower_bound) 个分区

例如:lower_bound = 1, upper_bound = 10, partition_num = 2
sql = "select * from test where age > 0 and age < 10"

分割结果

分割 1: select * from test where ($split_column >= 1 and $split_column < 6) and ( age > 0 and age < 10 )

分割 2: select * from test where ($split_column >= 6 and $split_column < 11) and ( age > 0 and age < 10 )

partition_num [int]

InfluxDB 的分区数量

提示:确保 upper_bound 减去 lower_bound 能被 partition_num 整除,否则查询结果会重叠

epoch [string]

返回的时间精度

  • 可选值:H, m, s, MS, u, n
  • 默认值:n

query_timeout_sec [int]

InfluxDB 的查询超时时间(秒)

connect_timeout_ms [long]

连接到 InfluxDB 的超时时间(毫秒)

通用选项

源插件通用参数,请参考 源通用选项 详见。

示例

多并行性和多分区扫描示例

source {

InfluxDB {
url = "http://influxdb-host:8086"
sql = "select label, value, rt, time from test"
database = "test"
upper_bound = 100
lower_bound = 1
partition_num = 4
split_column = "value"
schema {
fields {
label = STRING
value = INT
rt = STRING
time = BIGINT
}
}
}

}

不使用分区扫描的示例

source {

InfluxDB {
url = "http://influxdb-host:8086"
sql = "select label, value, rt, time from test"
database = "test"
schema {
fields {
label = STRING
value = INT
rt = STRING
time = BIGINT
}
}
}

}

变更日志

Change Log
ChangeCommitVersion
[Feature][Checkpoint] Add check script for source/sink state class serialVersionUID missing (#9118)https://github.com/apache/seatunnel/commit/4f5adeb1c72.3.11
[Improve] influxdb options (#8966)https://github.com/apache/seatunnel/commit/9f498b81332.3.10
[Improve] restruct connector common options (#8634)https://github.com/apache/seatunnel/commit/f3499a6eeb2.3.10
[Improve][dist]add shade check rule (#8136)https://github.com/apache/seatunnel/commit/51ef8000162.3.9
[Feature][Restapi] Allow metrics information to be associated to logical plan nodes (#7786)https://github.com/apache/seatunnel/commit/6b7c53d03c2.3.9
[Improve] Improve some connectors prepare check error message (#7465)https://github.com/apache/seatunnel/commit/6930a25edd2.3.8
[Improve][Connector] Add multi-table sink option check (#7360)https://github.com/apache/seatunnel/commit/2489f6446b2.3.7
[Feature][Core] Support using upstream table placeholders in sink options and auto replacement (#7131)https://github.com/apache/seatunnel/commit/c4ca74122c2.3.6
Support multi-table sink feature for influxdb (#6278)https://github.com/apache/seatunnel/commit/56f13e920d2.3.5
[Improve][Zeta] Add classloader cache mode to fix metaspace leak (#6355)https://github.com/apache/seatunnel/commit/9c3c2f183d2.3.5
[Test][E2E] Add thread leak check for connector (#5773)https://github.com/apache/seatunnel/commit/1f2f3fc5f02.3.4
[BugFix][InfluxDBSource] Resolve invalid SQL in initColumnsIndex method caused by direct QUERY_LIMIT appendage with 'tz' function. (#4829)https://github.com/apache/seatunnel/commit/deed9c62c32.3.4
[Improve][Common] Introduce new error define rule (#5793)https://github.com/apache/seatunnel/commit/9d1b2582b22.3.4
[Improve] Remove use SeaTunnelSink::getConsumedType method and mark it as deprecated (#5755)https://github.com/apache/seatunnel/commit/8de74081002.3.4
Support config column/primaryKey/constraintKey in schema (#5564)https://github.com/apache/seatunnel/commit/eac76b4e502.3.4
[Improve][Connector-V2] Remove scheduler in InfluxDB sink (#5271)https://github.com/apache/seatunnel/commit/f459f500cb2.3.4
[Improve][CheckStyle] Remove useless 'SuppressWarnings' annotation of checkstyle. (#5260)https://github.com/apache/seatunnel/commit/51c0d709ba2.3.4
Merge branch 'dev' into merge/cdchttps://github.com/apache/seatunnel/commit/4324ee19122.3.1
[Improve][Project] Code format with spotless plugin.https://github.com/apache/seatunnel/commit/423b5830382.3.1
[improve][api] Refactoring schema parse (#4157)https://github.com/apache/seatunnel/commit/b2f573a13e2.3.1
[Improve][build] Give the maven module a human readable name (#4114)https://github.com/apache/seatunnel/commit/d7cd6010512.3.1
[Improve][Project] Code format with spotless plugin. (#4101)https://github.com/apache/seatunnel/commit/a2ab1665612.3.1
[Improve][SourceConnector] Unifie InfluxDB source fields to schema (#3897)https://github.com/apache/seatunnel/commit/85a984a64f2.3.1
[Feature][Connector] add get source method to all source connector (#3846)https://github.com/apache/seatunnel/commit/417178fb842.3.1
[Feature][API &amp; Connector &amp; Doc] add parallelism and column projection interface (#3829)https://github.com/apache/seatunnel/commit/b9164b8ba12.3.1
[Hotfix][OptionRule] Fix option rule about all connectors (#3592)https://github.com/apache/seatunnel/commit/226dc6a1192.3.0
[Improve][Connector-V2][Influxdb] Unified exception for influxdb source & sink connector (#3558)https://github.com/apache/seatunnel/commit/4686f35d682.3.0
[Feature][Connector][influx] Expose configurable options in influx db (#3392)https://github.com/apache/seatunnel/commit/b247ff0aef2.3.0
[Feature][Connector-V2] influxdb sink connector (#3174)https://github.com/apache/seatunnel/commit/630e8847912.3.0
[Feature][Connector-V2] Add influxDB connector source (#2697)https://github.com/apache/seatunnel/commit/1d70ea30842.3.0-beta