Git Product home page Git Product logo

node-red-contrib-stackhero-influxdb-v2's Introduction

node-red-contrib-stackhero-influxdb-v2

Node-RED node to read and write to an InfluxDB v2 database.

Remember: if you like it, please star it! ๐Ÿฅฐ

Official repository: https://github.com/stackhero-io/node-red-contrib-stackhero-influxdb-v2

Sponsors

node-red-contrib-stackhero-influxdb-v2 is developed by Stackhero. If you are looking for powerful managed services, like InfluxDB, you should seriously consider Stackhero ๐Ÿค“

Usage

We have 2 nodes here. A write node, to send data to InfluxDB and a query node, to retrieve data using the Flux language.

Write data

The write node requires a payload object like this one:

msg.payload = {
  // You bucket
  // Optional (it can be defined in the node credentials settings)
  bucket: 'myBucket',

  // Precision of timestamp
  // Optional
  // Can be `ns` (nanoseconds),
  //        `us` (microseconds),
  //        `ms` (milliseconds),
  //        `s` (seconds).
  // The default is `ns`
  // Note: if you set the `timestamp` field to `Date.now()`, you have to set the `precision` to `ms`
  precision: 'ms',

  // Data to send to InfluxDB
  // Can be an array of objects or only one object
  data: [
    {
      measurement: 'machinerySensor',

      tags: {
        deviceId: 'gyh43',
        hardwareVersion: '1.0.2',
        softwareVersion: '2.5.1',
        location: 'factory-1'
      },

      fields: {
        temperature: 12,
        humidity: 46,
        vibrations: 18,
        batteryVoltage: 3.6
      },

      timestamp: Date.now()
    },

    // More data can be send here, simply re add an object
    // { ... },
  ]
};

return msg;

Example of the write node

Query data

The query node requires a topic string containing a Flux query.

msg.topic = 'from(bucket: "myBucket") |> range(start: -1h)';
return msg;

You can write multiple lines queries like this:

msg.topic = [
  'from(bucket: "myBucket")',
  '  |> range(start: -1d, stop: now)',
  '  |> filter(fn: (r) => r._measurement == "machinerySensor")',
  '  |> filter(fn: (r) => r._field == "vibrations")',
  '  |> aggregateWindow(every: 1h, fn: mean)',
  '  |> yield(name: "mean")',

  'from(bucket: "myBucket")',
  '  |> range(start: -1d, stop: now)',
  '  |> filter(fn: (r) => r._measurement == "machinerySensor")',
  '  |> filter(fn: (r) => r._field == "vibrations")',
  '  |> aggregateWindow(every: 1h, fn: max)',
  '  |> yield(name: "max")',
].join('\n');

return msg;

Example of the query node

node-red-contrib-stackhero-influxdb-v2's People

Contributors

bacto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.