Skip to content

InfluxDB Reader

InfluxDBReader plugin implements reading data from InfluxDB. The underlying implementation calls InfluxQL language to query tables and get returned data.

Example

The following example demonstrates how this plugin reads data from specified tables (i.e., metrics) and outputs to terminal

Create Required Database Tables and Data

Use the following commands to create tables and data to be read:

bash
# create database
influx --execute "CREATE DATABASE NOAA_water_database"
# download sample data
curl https://s3.amazonaws.com/noaa.water-database/NOAA_data.txt -o NOAA_data.txt
# import data via influx-cli
influx -import -path=NOAA_data.txt -precision=s -database=NOAA_water_database

Create Job File

Create job/influxdb2stream.json file with the following content:

json
{
  "job": {
    "content": {
      "reader": {
        "name": "influxdbreader",
        "parameter": {
          "column": [
            "*"
          ],
          "where": "1=1",
          "connection": {
            "endpoint": "http://localhost:8086",
            "database": "NOAA_water_database",
            "table": "h2o_feet"
          },
          "connTimeout": 15,
          "readTimeout": 20,
          "writeTimeout": 20,
          "username": "influx",
          "password": "influx123"
        }
      },
      "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/influxdb2stream.json

Parameters

ConfigurationRequiredData TypeDefault ValueDescription
endpointYesstringNoneInfluxDB connection string
usernameYesstringNoneUsername of data source
passwordNostringNonePassword for specified username of data source
databaseYesstringNoneDatabase specified by data source
tableYesstringNoneSelected table name to be synchronized
columnYeslistNoneCollection of column names to be synchronized in configured table, detailed description see rdbmreader
connTimeoutNoint15Set connection timeout value, in seconds
readTimeoutNoint20Set read timeout value, in seconds
writeTimeoutNoint20Set write timeout value, in seconds
whereNostringNoneFiltering conditions for the table
querySqlNostringNoneUse SQL query to get data, if configured, table and column configuration items are invalid

Type Conversion

Current implementation treats all fields as strings.

Limitations

  1. Current plugin only supports version 1.x, version 2.0 and above are not supported