InfluxDB Exporter Component
The InfluxDB Exporter component subscribes to a Bus and exports data matching subscription patterns to a configurable InfluxDB database.
The InfluxDB Exporter component can be configured to work with InfluxDB-1.x or InfluxDB-2.x. This component also supports batching the input data to optimize writes to InfluxDB.
InfluxDB Exporter Configuration Variables
The following table describes the generic configuration variables that are used with the InfluxDB Exporter component:
Parameter | Type | Description | Valid Values | Required |
---|---|---|---|---|
Library | String | The shared library implementing the command component | libxrt-influxdb-exporter.so | Y |
Factory | String | The name of the C function used to instantiate the component | xrt_influxdb_exporter_factory | Y |
InfluxVersion | Unsigned Integer | Indicate the InfluxDB Version to use | Valid values are as follows:
|
N |
ServerURI | String | The URI of the Server to use | URI where the influxDB server is running | Y |
Bus | String | The name of the Bus component to use | The name of an existing Bus component | Y |
Logger | String | The name of the Logger component to use | The name of an existing Logger component | N |
SelectData | Array | An array of selection data | See Select Data Configuration Variables | Y |
QueueSize | Unsigned Integer | The size of the queue for the subscriber to hold messages | Default: 4 | N |
ConnectTimeout | Unsigned Integer | The connection timeout in milliseconds | Default is 1000 | N |
Timeout | Unsigned Integer | The data transfer timeout in milliseconds | Default is 0 (no timeout during transfer) | N |
BatchConfig | Object | Batch configuration for incoming messages | See Batch Configuration Variables | N |
Include the following configuration variables to export data to:
InfluxDB-1.x
Parameter | Type | Description | Valid Values | Required |
---|---|---|---|---|
DBName | String | The name of the database to use | The name of the database | Y |
AuthEnabled | Boolean |
Determines user authentication
Set to true if auth-enabled is set to true in the influxdb.conf file |
Valid values are as follows:
|
N |
UserName | String |
User name for authentication
Set if AuthEnabled is set to true |
A valid username | N |
Password | String |
Password for authentication
Set if AuthEnabled is set to true |
A valid password | N |
InfluxDB-2.x
Parameter | Type | Description | Valid Values | Required |
---|---|---|---|---|
Bucket | String | Name of the bucket to use | The name of the created bucket | Y |
Org | String | Name of the Influx organization to use | The name of the created organization | Y |
Token | String | Access Token | The name of the created access token | Y |
Measurement | String | Influx Measurement | Valid values are as follows:
|
N |
Tags | String Array | Influx Tag(s) | Valid values are as follows:
|
N |
Note
Create organization, Bucket and Token using Web UI or influx CLI.
Required Device Service configuration:
- Set
TimeStamp
totrue
to get timestamp from the source. If not set, the data written to InfluxDB will be overwritten for batch writes (set usingBatchConfig
). - Set
PublishSource
totrue
to get the sourcename, required when Measurement is set toDeviceCommand
- Set
tags
to{"ScheduleName":"<name>"}
inschedules.json
to get the schedulename, required when Measurement or Tag is set toScheduleName
Select Data Configuration Variables
The following table describes the configuration variables that can be used to configure the selection data from various sources:
Parameter | Type | Description | Valid Values | Required |
---|---|---|---|---|
Format | Enum | The default JSON encoding used for data received from the device |
Valid values are as follows:
|
N |
Pattern | String | The pattern to match on the Bus component for subscription | Y | |
Scope | String |
The name to store as measurement
measurement is determined based on the value of Format, as follows:
|
Measurement identifier to use when Format is set to Raw | N |
Batch Configuration Variables
Parameter | Type | Description | Valid Values | Required |
---|---|---|---|---|
BatchSize | Unsigned Integer | The number of messages to batch before publishing them | Default: 0 | N |
BatchTimeout | Unsigned Integer | The interval in milliseconds for which batching occurs before the batch is published | Default: 0 | N |
Scheduler | String | The Scheduler component to use | The name of an existing Scheduler component | Y |
ThreadPool | String | The name of the Threadpool component to use | The name of an existing Threadpool component | Y |
Priority | Integer | The priority of the scheduler thread |
The range is system-dependent
For example on Linux it is usually between 1 and 100 with 1 being the lowest priority and 100 being the highest priority |
N |
InfluxDB Exporter Configuration Example
The following example configures an InfluxDB export component to write data to InfluxDB-1.x server:
{
"Library": "libxrt-influxdb-exporter.so",
"Factory": "xrt_influxdb_exporter_factory",
"ServerURI": "http://127.0.0.1:8086",
"DBName": "influxdb_test",
"AuthEnabled": true,
"UserName": "admin",
"Password": "admin",
"SelectData": [
{"Pattern": "device/data", "Format": "Device"}
],
"BatchConfig":
{
"BatchSize": 5,
"BatchTimeout": 5000,
"Scheduler":"sched",
"ThreadPool":"pool"
},
"Bus": "bus",
"Logger": "logger",
"ConnectTimeout": 750,
"Timeout": 1500
}
To write to InfluxDB-2.x, configure the InfluxDB exporter component as below :
{
"Library": "libxrt-influxdb-exporter.so",
"Factory": "xrt_influxdb_exporter_factory",
"InfluxVersion": 2,
"ServerURI": "http://127.0.0.1:8086",
"Bucket" : "test_bucket",
"Org": "IoTechSys",
"Token": "abcdef==",
"SelectData": [
{ "Pattern": "device/#", "Format": "Device"}
],
"Measurement": "DeviceCommand",
"Tags": ["TagScheduleName", "TagDeviceName"],
"BatchConfig":
{
"BatchSize": 5,
"BatchTimeout": 5000,
"Scheduler":"sched",
"ThreadPool":"pool"
},
"Bus": "bus",
"Logger": "logger_debug",
"ConnectTimeout": 4000,
"Timeout": 1500
}