InfluxDB2 Reader
InfluxDB2 Reader plugin implements reading data from InfluxDB version 2.0 and above.
Note: If your InfluxDB is version 1.8 and below, you should use the InfluxDBReader plugin.
Example
The following example demonstrates how this plugin reads data from specified tables (i.e., metrics) and outputs to terminal.
Create Job File
Create job/influx2stream.json file with the following content:
{
"job": {
"content": {
"reader": {
"name": "influxdb2reader",
"parameter": {
"column": [
"location",
"height",
"wet"
],
"connection": {
"endpoint": "http://localhost:8086",
"bucket": "test",
"table": [
"temperature"
],
"org": "com.wgzhao"
},
"token": "YOUR_SECURE_TOKEN",
"range": [
"-1h",
"-5m"
],
"limit": 10
}
},
"writer": {
"name": "streamwriter",
"parameter": {
"print": "true"
}
}
},
"setting": {
"speed": {
"bytes": -1,
"channel": 1
}
}
}
}Run
Execute the following command for data collection
bin/addax.sh job/influx2stream.jsonParameters
| Configuration | Required | Data Type | Default Value | Description |
|---|---|---|---|---|
| endpoint | Yes | string | None | InfluxDB connection string |
| token | Yes | string | None | Token for accessing database |
| table | No | list | None | Selected table names (i.e., metrics) to be synchronized |
| org | Yes | string | None | Specify InfluxDB org name |
| bucket | Yes | string | None | Specify InfluxDB bucket name |
| column | No | list | None | Collection of column names to be synchronized in configured table, detailed description see rdbmreader |
| range | Yes | list | None | Time range for reading data |
| limit | No | int | None | Limit number of records to get |
column
If column is not specified, or column is specified as ["*"], all valid _field fields and _time field will be read. Otherwise, read according to specified fields.
range
range is used to specify the time range for reading metrics, with the following format:
{
"range": ["start_time", "end_time"]
}range consists of a list of two strings, the first string represents start time, the second represents end time. The time expression format must comply with Flux format requirements, like this:
{
"range": ["-15h", "-2h"]
}If you don't want to specify the second end time, you can omit it, like this:
{
"range": ["-15h"]
}Type Conversion
Current implementation treats all fields as strings.
Limitations
- Current plugin only supports version 2.0 and above