Skip to content

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:

json
{
  "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

bash
bin/addax.sh job/influx2stream.json

Parameters

ConfigurationRequiredData TypeDefault ValueDescription
endpointYesstringNoneInfluxDB connection string
tokenYesstringNoneToken for accessing database
tableNolistNoneSelected table names (i.e., metrics) to be synchronized
orgYesstringNoneSpecify InfluxDB org name
bucketYesstringNoneSpecify InfluxDB bucket name
columnNolistNoneCollection of column names to be synchronized in configured table, detailed description see rdbmreader
rangeYeslistNoneTime range for reading data
limitNointNoneLimit 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:

json
{
  "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:

json
{
  "range": ["-15h", "-2h"]
}

If you don't want to specify the second end time, you can omit it, like this:

json
{
  "range": ["-15h"]
}

Type Conversion

Current implementation treats all fields as strings.

Limitations

  1. Current plugin only supports version 2.0 and above