Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stackhero-io/node-red-contrib-stackhero-influxdb-v2
Node-RED node to read and write to an InfluxDB v2 database.
https://github.com/stackhero-io/node-red-contrib-stackhero-influxdb-v2
influxdb2 node-red node-red-contrib stackhero
Last synced: 3 months ago
JSON representation
Node-RED node to read and write to an InfluxDB v2 database.
- Host: GitHub
- URL: https://github.com/stackhero-io/node-red-contrib-stackhero-influxdb-v2
- Owner: stackhero-io
- Created: 2020-05-11T07:53:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T19:38:54.000Z (over 1 year ago)
- Last Synced: 2024-07-25T17:30:44.161Z (4 months ago)
- Topics: influxdb2, node-red, node-red-contrib, stackhero
- Language: HTML
- Size: 165 KB
- Stars: 31
- Watchers: 2
- Forks: 7
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-nodered - stackhero-influxdb-v2 - Save and query data from an InfluxDB v2 time series database. (Nodes / Database)
README
# node-red-contrib-stackhero-influxdb-v2
[Node-RED](https://nodered.org) 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](https://github.com/stackhero-io/node-red-contrib-stackhero-influxdb-v2)
## Sponsors
`node-red-contrib-stackhero-influxdb-v2` is developed by [Stackhero](https://www.stackhero.io/).
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:
```javascript
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](https://raw.githubusercontent.com/stackhero-io/node-red-contrib-stackhero-influxdb-v2/master/assets/screenshotWrite.png)
### Query data
The query node requires a topic string containing a Flux query.
```javascript
msg.topic = 'from(bucket: "myBucket") |> range(start: -1h)';
return msg;
```You can write multiple lines queries like this:
```javascript
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](https://raw.githubusercontent.com/stackhero-io/node-red-contrib-stackhero-influxdb-v2/master/assets/screenshotQuery.png)