node-red-contrib-influxdb3 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/README.md +377 -339
- package/examples/basic-flow.json +170 -170
- package/examples/mqtt-to-influx.json +134 -134
- package/influxdb3.html +228 -204
- package/influxdb3.js +303 -207
- package/package.json +42 -38
- package/renovate.json +6 -0
package/influxdb3.html
CHANGED
|
@@ -1,204 +1,228 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
InfluxDB v3 Configuration Node
|
|
3
|
-
-->
|
|
4
|
-
<script type="text/javascript">
|
|
5
|
-
RED.nodes.registerType('influxdb3-config', {
|
|
6
|
-
category: 'config',
|
|
7
|
-
defaults: {
|
|
8
|
-
name: { value: '' },
|
|
9
|
-
host: { value: '', required: true },
|
|
10
|
-
database: { value: '', required: true }
|
|
11
|
-
},
|
|
12
|
-
credentials: {
|
|
13
|
-
token: { type: 'password' }
|
|
14
|
-
},
|
|
15
|
-
label: function() {
|
|
16
|
-
return this.name || this.host || 'InfluxDB v3';
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<script type="text/html" data-template-name="influxdb3-config">
|
|
22
|
-
<div class="form-row">
|
|
23
|
-
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
-
<input type="text" id="node-config-input-name" placeholder="Connection name">
|
|
25
|
-
</div>
|
|
26
|
-
<div class="form-row">
|
|
27
|
-
<label for="node-config-input-host"><i class="fa fa-server"></i> Host</label>
|
|
28
|
-
<input type="text" id="node-config-input-host" placeholder="https://us-east-1-1.aws.cloud2.influxdata.com">
|
|
29
|
-
</div>
|
|
30
|
-
<div class="form-row">
|
|
31
|
-
<label for="node-config-input-token"><i class="fa fa-key"></i> Token</label>
|
|
32
|
-
<input type="password" id="node-config-input-token">
|
|
33
|
-
</div>
|
|
34
|
-
<div class="form-row">
|
|
35
|
-
<label for="node-config-input-database"><i class="fa fa-database"></i> Database</label>
|
|
36
|
-
<input type="text" id="node-config-input-database" placeholder="my-database">
|
|
37
|
-
</div>
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
<script type="text/html" data-help-name="influxdb3-config">
|
|
41
|
-
<p>Configuration node for InfluxDB v3 connection.</p>
|
|
42
|
-
<h3>Details</h3>
|
|
43
|
-
<p>This configuration node stores the connection details for an InfluxDB v3 instance.</p>
|
|
44
|
-
<dl class="message-properties">
|
|
45
|
-
<dt>Name <span class="property-type">string</span></dt>
|
|
46
|
-
<dd>A friendly name for this connection</dd>
|
|
47
|
-
<dt>Host <span class="property-type">string</span></dt>
|
|
48
|
-
<dd>The InfluxDB v3 host URL (e.g., https://us-east-1-1.aws.cloud2.influxdata.com)</dd>
|
|
49
|
-
<dt>Token <span class="property-type">string</span></dt>
|
|
50
|
-
<dd>The authentication token for accessing InfluxDB v3</dd>
|
|
51
|
-
<dt>Database <span class="property-type">string</span></dt>
|
|
52
|
-
<dd>The default database (bucket) name to write to</dd>
|
|
53
|
-
</dl>
|
|
54
|
-
</script>
|
|
55
|
-
|
|
56
|
-
<!--
|
|
57
|
-
InfluxDB v3 Write Node
|
|
58
|
-
-->
|
|
59
|
-
<script type="text/javascript">
|
|
60
|
-
RED.nodes.registerType('influxdb3-write', {
|
|
61
|
-
category: 'storage',
|
|
62
|
-
color: '#9ea8db',
|
|
63
|
-
defaults: {
|
|
64
|
-
influxdb: { type: 'influxdb3-config', required: true },
|
|
65
|
-
name: { value: '' },
|
|
66
|
-
measurement: { value: '' },
|
|
67
|
-
database: { value: '' }
|
|
68
|
-
},
|
|
69
|
-
inputs: 1,
|
|
70
|
-
outputs: 1,
|
|
71
|
-
icon: 'db.png',
|
|
72
|
-
label: function() {
|
|
73
|
-
return this.name || 'influxdb3 write';
|
|
74
|
-
},
|
|
75
|
-
labelStyle: function() {
|
|
76
|
-
return this.name ? 'node_label_italic' : '';
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
</script>
|
|
80
|
-
|
|
81
|
-
<script type="text/html" data-template-name="influxdb3-write">
|
|
82
|
-
<div class="form-row">
|
|
83
|
-
<label for="node-input-influxdb"><i class="fa fa-server"></i> Connection</label>
|
|
84
|
-
<input type="text" id="node-input-influxdb">
|
|
85
|
-
</div>
|
|
86
|
-
<div class="form-row">
|
|
87
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
88
|
-
<input type="text" id="node-input-name" placeholder="Name">
|
|
89
|
-
</div>
|
|
90
|
-
<div class="form-row">
|
|
91
|
-
<label for="node-input-measurement"><i class="fa fa-chart-line"></i> Measurement</label>
|
|
92
|
-
<input type="text" id="node-input-measurement" placeholder="Leave empty to use msg.measurement">
|
|
93
|
-
</div>
|
|
94
|
-
<div class="form-row">
|
|
95
|
-
<label for="node-input-database"><i class="fa fa-database"></i> Database</label>
|
|
96
|
-
<input type="text" id="node-input-database" placeholder="Override default database (optional)">
|
|
97
|
-
</div>
|
|
98
|
-
</script>
|
|
99
|
-
|
|
100
|
-
<script type="text/html" data-help-name="influxdb3-write">
|
|
101
|
-
<p>Writes data to InfluxDB v3.</p>
|
|
102
|
-
|
|
103
|
-
<h3>Inputs</h3>
|
|
104
|
-
<dl class="message-properties">
|
|
105
|
-
<dt>payload <span class="property-type">string | object</span></dt>
|
|
106
|
-
<dd>The data to write. Can be either:
|
|
107
|
-
<ul>
|
|
108
|
-
<li>A string in line protocol format</li>
|
|
109
|
-
<li>An object with <code>fields</code> (required) and optionally <code>tags</code> and <code>timestamp</code></li>
|
|
110
|
-
</ul>
|
|
111
|
-
</dd>
|
|
112
|
-
<dt class="optional">measurement <span class="property-type">string</span></dt>
|
|
113
|
-
<dd>Override the measurement name configured in the node</dd>
|
|
114
|
-
<dt class="optional">database <span class="property-type">string</span></dt>
|
|
115
|
-
<dd>Override the database configured in the node or connection</dd>
|
|
116
|
-
<dt class="optional">timestamp <span class="property-type">Date | number</span></dt>
|
|
117
|
-
<dd>Timestamp for the data point (if not in payload)</dd>
|
|
118
|
-
</dl>
|
|
119
|
-
|
|
120
|
-
<h3>Outputs</h3>
|
|
121
|
-
<dl class="message-properties">
|
|
122
|
-
<dt>payload <span class="property-type">object</span></dt>
|
|
123
|
-
<dd>The original payload is passed through</dd>
|
|
124
|
-
</dl>
|
|
125
|
-
|
|
126
|
-
<h3>Details</h3>
|
|
127
|
-
<p>This node writes data to InfluxDB v3. The data can be provided in two formats:</p>
|
|
128
|
-
|
|
129
|
-
<h4>Line Protocol Format</h4>
|
|
130
|
-
<p>Send a string in line protocol format:</p>
|
|
131
|
-
<pre>msg.payload = "temperature,location=room1 value=21.5";</pre>
|
|
132
|
-
|
|
133
|
-
<h4>Object Format</h4>
|
|
134
|
-
<p>Send an object with fields and optionally tags:</p>
|
|
135
|
-
<pre>{
|
|
136
|
-
"fields": {
|
|
137
|
-
"temperature": 21.5,
|
|
138
|
-
"humidity": 65
|
|
139
|
-
},
|
|
140
|
-
"tags": {
|
|
141
|
-
"location": "room1",
|
|
142
|
-
"sensor": "dht22"
|
|
143
|
-
},
|
|
144
|
-
"timestamp": Date.now()
|
|
145
|
-
}</pre>
|
|
146
|
-
|
|
147
|
-
<h4>Simplified Object Format</h4>
|
|
148
|
-
<p>Send an object where all properties (except 'tags' and 'timestamp') are treated as fields:</p>
|
|
149
|
-
<pre>{
|
|
150
|
-
"temperature": 21.5,
|
|
151
|
-
"humidity": 65,
|
|
152
|
-
"tags": {
|
|
153
|
-
"location": "room1"
|
|
154
|
-
}
|
|
155
|
-
}</pre>
|
|
156
|
-
|
|
157
|
-
<h3>
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
1
|
+
<!--
|
|
2
|
+
InfluxDB v3 Configuration Node
|
|
3
|
+
-->
|
|
4
|
+
<script type="text/javascript">
|
|
5
|
+
RED.nodes.registerType('influxdb3-config', {
|
|
6
|
+
category: 'config',
|
|
7
|
+
defaults: {
|
|
8
|
+
name: { value: '' },
|
|
9
|
+
host: { value: '', required: true },
|
|
10
|
+
database: { value: '', required: true }
|
|
11
|
+
},
|
|
12
|
+
credentials: {
|
|
13
|
+
token: { type: 'password' }
|
|
14
|
+
},
|
|
15
|
+
label: function() {
|
|
16
|
+
return this.name || this.host || 'InfluxDB v3';
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script type="text/html" data-template-name="influxdb3-config">
|
|
22
|
+
<div class="form-row">
|
|
23
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
+
<input type="text" id="node-config-input-name" placeholder="Connection name">
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-config-input-host"><i class="fa fa-server"></i> Host</label>
|
|
28
|
+
<input type="text" id="node-config-input-host" placeholder="https://us-east-1-1.aws.cloud2.influxdata.com">
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-config-input-token"><i class="fa fa-key"></i> Token</label>
|
|
32
|
+
<input type="password" id="node-config-input-token">
|
|
33
|
+
</div>
|
|
34
|
+
<div class="form-row">
|
|
35
|
+
<label for="node-config-input-database"><i class="fa fa-database"></i> Database</label>
|
|
36
|
+
<input type="text" id="node-config-input-database" placeholder="my-database">
|
|
37
|
+
</div>
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<script type="text/html" data-help-name="influxdb3-config">
|
|
41
|
+
<p>Configuration node for InfluxDB v3 connection.</p>
|
|
42
|
+
<h3>Details</h3>
|
|
43
|
+
<p>This configuration node stores the connection details for an InfluxDB v3 instance.</p>
|
|
44
|
+
<dl class="message-properties">
|
|
45
|
+
<dt>Name <span class="property-type">string</span></dt>
|
|
46
|
+
<dd>A friendly name for this connection</dd>
|
|
47
|
+
<dt>Host <span class="property-type">string</span></dt>
|
|
48
|
+
<dd>The InfluxDB v3 host URL (e.g., https://us-east-1-1.aws.cloud2.influxdata.com)</dd>
|
|
49
|
+
<dt>Token <span class="property-type">string</span></dt>
|
|
50
|
+
<dd>The authentication token for accessing InfluxDB v3</dd>
|
|
51
|
+
<dt>Database <span class="property-type">string</span></dt>
|
|
52
|
+
<dd>The default database (bucket) name to write to</dd>
|
|
53
|
+
</dl>
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<!--
|
|
57
|
+
InfluxDB v3 Write Node
|
|
58
|
+
-->
|
|
59
|
+
<script type="text/javascript">
|
|
60
|
+
RED.nodes.registerType('influxdb3-write', {
|
|
61
|
+
category: 'storage',
|
|
62
|
+
color: '#9ea8db',
|
|
63
|
+
defaults: {
|
|
64
|
+
influxdb: { type: 'influxdb3-config', required: true },
|
|
65
|
+
name: { value: '' },
|
|
66
|
+
measurement: { value: '' },
|
|
67
|
+
database: { value: '' }
|
|
68
|
+
},
|
|
69
|
+
inputs: 1,
|
|
70
|
+
outputs: 1,
|
|
71
|
+
icon: 'db.png',
|
|
72
|
+
label: function() {
|
|
73
|
+
return this.name || 'influxdb3 write';
|
|
74
|
+
},
|
|
75
|
+
labelStyle: function() {
|
|
76
|
+
return this.name ? 'node_label_italic' : '';
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<script type="text/html" data-template-name="influxdb3-write">
|
|
82
|
+
<div class="form-row">
|
|
83
|
+
<label for="node-input-influxdb"><i class="fa fa-server"></i> Connection</label>
|
|
84
|
+
<input type="text" id="node-input-influxdb">
|
|
85
|
+
</div>
|
|
86
|
+
<div class="form-row">
|
|
87
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
88
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
89
|
+
</div>
|
|
90
|
+
<div class="form-row">
|
|
91
|
+
<label for="node-input-measurement"><i class="fa fa-chart-line"></i> Measurement</label>
|
|
92
|
+
<input type="text" id="node-input-measurement" placeholder="Leave empty to use msg.measurement">
|
|
93
|
+
</div>
|
|
94
|
+
<div class="form-row">
|
|
95
|
+
<label for="node-input-database"><i class="fa fa-database"></i> Database</label>
|
|
96
|
+
<input type="text" id="node-input-database" placeholder="Override default database (optional)">
|
|
97
|
+
</div>
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<script type="text/html" data-help-name="influxdb3-write">
|
|
101
|
+
<p>Writes data to InfluxDB v3.</p>
|
|
102
|
+
|
|
103
|
+
<h3>Inputs</h3>
|
|
104
|
+
<dl class="message-properties">
|
|
105
|
+
<dt>payload <span class="property-type">string | object</span></dt>
|
|
106
|
+
<dd>The data to write. Can be either:
|
|
107
|
+
<ul>
|
|
108
|
+
<li>A string in line protocol format</li>
|
|
109
|
+
<li>An object with <code>fields</code> (required) and optionally <code>tags</code> and <code>timestamp</code></li>
|
|
110
|
+
</ul>
|
|
111
|
+
</dd>
|
|
112
|
+
<dt class="optional">measurement <span class="property-type">string</span></dt>
|
|
113
|
+
<dd>Override the measurement name configured in the node</dd>
|
|
114
|
+
<dt class="optional">database <span class="property-type">string</span></dt>
|
|
115
|
+
<dd>Override the database configured in the node or connection</dd>
|
|
116
|
+
<dt class="optional">timestamp <span class="property-type">Date | number</span></dt>
|
|
117
|
+
<dd>Timestamp for the data point (if not in payload)</dd>
|
|
118
|
+
</dl>
|
|
119
|
+
|
|
120
|
+
<h3>Outputs</h3>
|
|
121
|
+
<dl class="message-properties">
|
|
122
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
123
|
+
<dd>The original payload is passed through</dd>
|
|
124
|
+
</dl>
|
|
125
|
+
|
|
126
|
+
<h3>Details</h3>
|
|
127
|
+
<p>This node writes data to InfluxDB v3. The data can be provided in two formats:</p>
|
|
128
|
+
|
|
129
|
+
<h4>Line Protocol Format</h4>
|
|
130
|
+
<p>Send a string in line protocol format:</p>
|
|
131
|
+
<pre>msg.payload = "temperature,location=room1 value=21.5";</pre>
|
|
132
|
+
|
|
133
|
+
<h4>Object Format</h4>
|
|
134
|
+
<p>Send an object with fields and optionally tags:</p>
|
|
135
|
+
<pre>{
|
|
136
|
+
"fields": {
|
|
137
|
+
"temperature": 21.5,
|
|
138
|
+
"humidity": 65
|
|
139
|
+
},
|
|
140
|
+
"tags": {
|
|
141
|
+
"location": "room1",
|
|
142
|
+
"sensor": "dht22"
|
|
143
|
+
},
|
|
144
|
+
"timestamp": Date.now()
|
|
145
|
+
}</pre>
|
|
146
|
+
|
|
147
|
+
<h4>Simplified Object Format</h4>
|
|
148
|
+
<p>Send an object where all properties (except 'tags' and 'timestamp') are treated as fields:</p>
|
|
149
|
+
<pre>{
|
|
150
|
+
"temperature": 21.5,
|
|
151
|
+
"humidity": 65,
|
|
152
|
+
"tags": {
|
|
153
|
+
"location": "room1"
|
|
154
|
+
}
|
|
155
|
+
}</pre>
|
|
156
|
+
|
|
157
|
+
<h3>Data Types</h3>
|
|
158
|
+
<p><strong>Important:</strong> By default, <strong>all numbers are written as floats</strong> to avoid schema conflicts.
|
|
159
|
+
JavaScript doesn't distinguish between <code>1.0</code> and <code>1</code>, which can cause issues when InfluxDB expects a float.</p>
|
|
160
|
+
|
|
161
|
+
<h4>Writing Integer Fields</h4>
|
|
162
|
+
<p>To explicitly write integers, use one of these methods:</p>
|
|
163
|
+
|
|
164
|
+
<p><strong>Method 1: Using the <code>integers</code> array</strong></p>
|
|
165
|
+
<pre>msg.payload = {
|
|
166
|
+
fields: {
|
|
167
|
+
temperature: 21.5, // float
|
|
168
|
+
count: 42 // will be float by default
|
|
169
|
+
},
|
|
170
|
+
integers: ['count'] // mark count as integer
|
|
171
|
+
};</pre>
|
|
172
|
+
|
|
173
|
+
<p><strong>Method 2: Using the <code>i</code> suffix</strong></p>
|
|
174
|
+
<pre>msg.payload = {
|
|
175
|
+
fields: {
|
|
176
|
+
temperature: 21.5, // float
|
|
177
|
+
count: "42i" // integer (string with 'i' suffix)
|
|
178
|
+
}
|
|
179
|
+
};</pre>
|
|
180
|
+
|
|
181
|
+
<h3>Configuration</h3>
|
|
182
|
+
<dl class="message-properties">
|
|
183
|
+
<dt>Connection</dt>
|
|
184
|
+
<dd>The InfluxDB v3 connection configuration</dd>
|
|
185
|
+
<dt>Measurement</dt>
|
|
186
|
+
<dd>The measurement name to use. Can be overridden by <code>msg.measurement</code></dd>
|
|
187
|
+
<dt>Database</dt>
|
|
188
|
+
<dd>Optional database override. If not set, uses the database from the connection config</dd>
|
|
189
|
+
</dl>
|
|
190
|
+
|
|
191
|
+
<h3>Examples</h3>
|
|
192
|
+
<h4>Example 1: Simple temperature reading</h4>
|
|
193
|
+
<pre>msg.measurement = "temperature";
|
|
194
|
+
msg.payload = {
|
|
195
|
+
"fields": {
|
|
196
|
+
"value": 21.5
|
|
197
|
+
},
|
|
198
|
+
"tags": {
|
|
199
|
+
"location": "living_room"
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
return msg;</pre>
|
|
203
|
+
|
|
204
|
+
<h4>Example 2: Multiple sensor values</h4>
|
|
205
|
+
<pre>msg.measurement = "environment";
|
|
206
|
+
msg.payload = {
|
|
207
|
+
"temperature": 21.5,
|
|
208
|
+
"humidity": 65,
|
|
209
|
+
"pressure": 1013.25,
|
|
210
|
+
"tags": {
|
|
211
|
+
"room": "bedroom",
|
|
212
|
+
"floor": "2"
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
return msg;</pre>
|
|
216
|
+
|
|
217
|
+
<h4>Example 3: Line protocol string</h4>
|
|
218
|
+
<pre>msg.payload = "weather,location=garden temperature=18.5,humidity=75";
|
|
219
|
+
return msg;</pre>
|
|
220
|
+
|
|
221
|
+
<h3>References</h3>
|
|
222
|
+
<ul>
|
|
223
|
+
<li><a href="https://github.com/InfluxCommunity/influxdb3-js">InfluxDB v3 JavaScript Client</a></li>
|
|
224
|
+
<li><a href="https://docs.influxdata.com/influxdb/v3/">InfluxDB v3 Documentation</a></li>
|
|
225
|
+
<li><a href="https://docs.influxdata.com/influxdb/v3/reference/syntax/line-protocol/">Line Protocol Reference</a></li>
|
|
226
|
+
</ul>
|
|
227
|
+
</script>
|
|
228
|
+
|