# node-red-contrib-influxdb
<a href="http://nodered.org" target="_new">Node-RED</a> nodes to write and query data from an InfluxDB time series database.
These nodes support both InfluxDB 1.x and InfluxDb 2.0 databases selected using the **Version** combo box in the configuration node. See the documentation of the different nodes to understand the options provided by the different versions. Currently the node uses two client libraries.
When version **1.x** is selected these nodes use the <a href="https://www.npmjs.com/package/influx" target="_new">influxDB 1.x client</a> for node.js, specifically calling the **writePoints()**, and **query()** methods. Currently they can only communicate with one influxdb host. These nodes are used for writing and querying data in InfluxDB 1.x to 1.8+.
When version **1.8-flux** is selected, the nodes use the <a href="https://docs.influxdata.com/influxdb/v1.8/tools/api/#influxdb-2-0-api-compatibility-endpoints" target="_new"> influxDB 2.0 API compatibility endpoints</a> available in the <a href="https://github.com/influxdata/influxdb-client-js" target="_new">InfluxDB 2.0 client libraries</a> for node.js. These nodes are used for writing and querying data with Flux in InfluxDB 1.8+.
When version **2.0** is selected, the nodes make use of the <a href="https://github.com/influxdata/influxdb-client-js" target="_new">InfluxDB 2.0 client libraries</a> for writing and querying data with Flux in InfluxDB 2.0.
## Prerequisites
To run this you'll need access to an InfluxDB database version 1.x, 1.8+ or 2.0. See the <a href="https://influxdb.com/" target="_new">InfluxDB site</a> for more information. The latest release of this node has been tested with InfluxDB 1.8 and 2.0. This node supports Node.js 10.x, 12.x and 14.x LTS releases. It does **not** support Node.js 8.x. This node does not support Node-RED before version 1.0.
## Install
You can use the Node-RED *Manage Palette* feature, or run the following command in the root directory of your Node-RED install. Usually this is `~/.node-red` .
npm install node-red-contrib-influxdb
## Usage
Nodes to write and query data from an influxdb time series database. Supports InfluxDb versions 1.x to 2.0.
### Input Node
Queries one or more measurements in an influxdb database. The query is specified in the node configuration or in the ***msg.query*** property. Setting it in the node will override the ***msg.query***. The result is returned in ***msg.payload***.
With a v1.x InfluxDb configuration, use the [InfluxQL query syntax](https://docs.influxdata.com/influxdb/v1.8/query_language/). With a v1.8-Flux or 2.0 configuration, use the [Flux query syntax](https://docs.influxdata.com/influxdb/v2.0/query-data/get-started/).
For example, here is a simple flow to query all of the points in the `test` measurement of the `test` database. The query is in the configuration of the influxdb input node (copy and paste to your Node-RED editor). We are using a v1.x InfluxDb here, so an InfluxQL query is used.
[{"id":"39aa2ca9.804da4","type":"debug","z":"6256f76b.e596d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":100,"wires":[]},{"id":"262a3923.e7b216","type":"influxdb in","z":"6256f76b.e596d8","influxdb":"eeb221fb.ab27f","name":"","query":"SELECT * from test","rawOutput":false,"precision":"","retentionPolicy":"","org":"my-org","x":310,"y":100,"wires":[["39aa2ca9.804da4"]]},{"id":"803d82f.ff80f8","type":"inject","z":"6256f76b.e596d8","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":100,"wires":[["262a3923.e7b216"]]},{"id":"eeb221fb.ab27f","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"test","name":"test","usetls":true,"tls":"d50d0c9f.31e858","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]
In this example, we query the same database for all points from a day ago using a **1.8-flux** configuration using the Flux query language:
[{"id":"dd32f825.863798","type":"influxdb in","z":"6256f76b.e596d8","influxdb":"2ff2a476.a6d2ec","name":"","query":"from(bucket: \"test/autogen\") |> range(start: -1d, stop: now())","rawOutput":false,"precision":"","retentionPolicy":"","org":"my-org","x":410,"y":220,"wires":[["17314806.c732c8"]]},{"id":"17314806.c732c8","type":"debug","z":"6256f76b.e596d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":280,"wires":[]},{"id":"eadef241.cf6fd","type":"inject","z":"6256f76b.e596d8","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":160,"wires":[["dd32f825.863798"]]},{"id":"2ff2a476.a6d2ec","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"database","name":"test 1.8 flux","usetls":false,"tls":"d50d0c9f.31e858","influxdbVersion":"1.8-flux","url":"https://localhost:8086","rejectUnauthorized":false},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]
This flow performs the same, but using the ***msg.query*** property:
[{"id":"2d5d7690.e5e77a","type":"influxdb in","z":"6256f76b.e596d8","influxdb":"2ff2a476.a6d2ec","name":"","query":"","rawOutput":false,"precision":"","retentionPolicy":"","org":"my-org","x":300,"y":380,"wires":[["6ab91739.fa71b8"]]},{"id":"6ab91739.fa71b8","type":"debug","z":"6256f76b.e596d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":490,"y":380,"wires":[]},{"id":"daff744d.5538c8","type":"function","z":"6256f76b.e596d8","name":"set query","func":"msg.query = 'from(bucket: \"test/autogen\") |> range(start: -1d, stop: now())'\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":300,"wires":[["2d5d7690.e5e77a"]]},{"id":"3e65472c.652658","type":"inject","z":"6256f76b.e596d8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":300,"wires":[["daff744d.5538c8"]]},{"id":"2ff2a476.a6d2ec","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"database","name":"test 1.8 flux","usetls":false,"tls":"d50d0c9f.31e858","influxdbVersion":"1.8-flux","url":"https://localhost:8086","rejectUnauthorized":false},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]
The function node in this flow sets the `msg.query` property as follows:
msg.query = 'from(bucket: "test/autogen") |> range(start: -1d, stop: now())'
return msg;
### Output Node
Writes one or more points (fields and tags) to a measurement.
The fields and tags to write are in ***msg.payload***. If the message is a string, number, or boolean, it will be written as a single field to the specified measurement called *value*.
>Note: Javascript numbers are *always* written as a float. When using the 1.8-flux or 2.0 configuration, you can explicitly write an integer using a number in a string with an 'i' suffix, for example, to write the integer `1234` use the string `'1234i'`. This is *not* supported using 1.x configurations; all numbers are written as float values.
For example, the following flow injects a single random field called `value` into the measurement `test` in the database `test` with the current timestamp.
[{"id":"17bd4566.e842bb","type":"influxdb out","z":"6256f76b.e596d8","influxdb":"eeb221fb.ab27f","name":"","measurement":"test","precision":"","retentionPolicy":"","database":"","retentionPolicyV18Flux":"","org":"","buc
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
节点红色贡献流 节点用于从InfluxDB时间序列数据库写入和查询数据。 这些节点支持使用配置节点中的“版本”组合框选择的InfluxDB 1.x和InfluxDb 2.0数据库。 请参阅不同节点的文档,以了解不同版本提供的选项。 当前,该节点使用两个客户端库。 选择版本1.x时,这些节点将用于node.js,特别是调用writePoints()和query()方法。 目前,他们只能与一台influxdb主机通信。 这些节点用于在InfluxDB 1.x到1.8+中写入和查询数据。 选择版本1.8-flux时,节点将使用用于node.js的。 这些节点用于在InfluxDB 1.8+中使用Flux写入和查询数据。 选择2.0版时,节点将使用在InfluxDB 2.0中使用Flux写入和查询数据。 先决条件 要运行此程序,您需要访问InfluxDB数据库版本1.x,1.8 +或2.0
资源详情
资源评论
资源推荐
收起资源包目录


























共 18 条
- 1








格式:zip 资源大小:293.0KB














格式:zip 资源大小:46.9KB





格式:zip 资源大小:60.2KB





流浪的夏先森
- 粉丝: 36
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 基于JavaBean的通用数据库访问设计.docx
- 系统集成项目管理工程师软考下午题及答案.doc
- 基于互联网+视角下的智能共享储物柜可行性研究.docx
- 《汽车电气设备》课程的项目管理化教学改革.doc
- 煤矿群众文化信息化的发展.docx
- 机械设计制造及其自动化中计算机技术的应用分析.docx
- 为什么这世界需要云计算.ppt
- 网络经济时代下的企业战略管理.doc
- 数据结构用c语言实现停车场管理完整.doc
- 博物馆弱电信息化系统设计方案.doc
- 2018年上半年信息系统项目管理师真题+答案.docx
- 继教档案信息化促进医院学术氛围营造的探究.docx
- JSP的图书管理完整.doc
- 大数据个人信用体系、模型及案例综述.docx
- 地下室防水工程监理细则vb.doc
- 《单片机应用技术C语言版》试卷A.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

评论0