Home

Awesome

barnacles-influxdb2

barnacles-influxdb2 writes ambient IoT timeseries data to InfluxDB v2.

Overview of barnacles-influxdb2

barnacles-influxdb2 ingests a real-time stream of dynamb objects from barnacles which it writes to a given InfluxDB v2 instance. It couples seamlessly with reelyActive's Pareto Anywhere open source IoT middleware.

barnacles-influxdb2 is a lightweight Node.js package that can run on resource-constrained edge devices as well as on powerful cloud servers and anything in between.

Pareto Anywhere integration

A common application of barnacles-influxdb2 is to write IoT data from pareto-anywhere to an InfluxDB v2 timeseries database. Simply follow our Create a Pareto Anywhere startup script tutorial using the script below:

#!/usr/bin/env node

const ParetoAnywhere = require('../lib/paretoanywhere.js');

// Edit the options to specify the InfluxDB v2 instance
const BARNACLES_INFLUXDB2_OPTIONS = {};

// ----- Exit gracefully if the optional dependency is not found -----
let BarnaclesInfluxDB2;
try {
  BarnaclesInfluxDB2 = require('barnacles-influxdb2');
}
catch(err) {
  console.log('This script requires barnacles-influxdb2.  Install with:');
  console.log('\r\n    "npm install barnacles-influxdb2"\r\n');
  return console.log('and then run this script again.');
}
// -------------------------------------------------------------------

let pa = new ParetoAnywhere();
pa.barnacles.addInterface(BarnaclesInfluxDB2, BARNACLES_INFLUXDB2_OPTIONS);

Supported dynamb properties

barnacles-influxdb2 converts standard dynamb properties into the following InfluxDB v2 types:

PropertyInfluxDB v2 typeConversion
accelerationFloatRMS of x, y, z
amperageFloatnone
angleOfRotationFloatnone
amperagesFloatRMS of all values
batteryPercentageFloatnone
batteryVoltageFloatnone
distanceFloatnone
elevationFloatnone
headingFloatnone
heartRateFloatnone
illuminanceFloatnone
isButtonPressedBooleanLogical OR of all values
isContactDetectedBooleanLogical OR of all values
isHealthyBooleannone
isMotionDetectedBooleanLogical OR of all values
isLiquidDetectedBooleanLogical OR of all values
levelPercentageFloatnone
magneticFieldFloatRMS of x, y, z
numberOfOccupantsUnsigned Integernone
passageCountsUnsigned IntegerSum of all values
pressureFloatnone
pressuresFloatRMS of all values
relativeHumidityFloatnone
speedFloatnone
temperatureFloatnone
temperaturesFloatRMS of all values
txCountUnsigned Integernone
uptimeUnsigned Integernone
voltageFloatnone
voltagesFloatRMS of all values

Options

barnacles-influxdb2 supports the following options:

PropertyDefaultDescription
url"http://localhost:8086"Local InfluxDB2 instance
tokenprocess.env.INFLUXDB_TOKENSecret token
org"reelyActive"Organisation
bucket"pareto-anywhere"Bucket

To set the INFLUXDB_TOKEN as an environment variable in Linux:

export INFLUXDB_TOKEN=pasteTokenHere

Contributing

Discover how to contribute to this open source project which upholds a standard code of conduct.

Security

Consult our security policy for best practices using this open source software and to report vulnerabilities.

License

MIT License

Copyright (c) 2023-2024 reelyActive

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.