iobroker.influxdb 2.4.0 → 2.5.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 +1 -1
- package/README.md +80 -23
- package/io-package.json +38 -44
- package/lib/Database.js +6 -5
- package/lib/DatabaseInfluxDB1x.js +18 -17
- package/lib/DatabaseInfluxDB2x.js +65 -70
- package/lib/aggregate.js +141 -37
- package/main.js +475 -169
- package/package.json +9 -9
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2016-
|
|
3
|
+
Copyright (c) 2016-2022 bluefox <dogafox@gmail.com>, apollon77
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -36,10 +36,10 @@ When doing custom queries via the "query" message you can use Flux queries to se
|
|
|
36
36
|
#### Store metadata information as tags instead of fields
|
|
37
37
|
For Influx 1.x state value, as well as associated metadata fields (`q`, `ack` and `from`) are stored as fields within InfluxDB. When using Flux-commands to retrieve this data (instead of InfluxQL) the data is returned in separate tables, which makes it more difficult to view the data in a joined way when using external database clients or Influx CLI `query` command. This is by design, as Influx only supports one field per data-point.
|
|
38
38
|
|
|
39
|
-
With Influx 2.x it is now also possible, to store this metadata-information besides the actual value of the state as Influx Tags. Tags are indexed and allow for faster search queries. In addition they are closely linked to the measurement stored within the db, meaning they will be returned in one table with the queried measurement which makes them much easier to handle, when used outside
|
|
39
|
+
With Influx 2.x it is now also possible, to store this metadata-information besides the actual value of the state as Influx Tags. Tags are indexed and allow for faster search queries. In addition, they are closely linked to the measurement stored within the db, meaning they will be returned in one table with the queried measurement which makes them much easier to handle, when used outside this adapter. There are limitations with this however:
|
|
40
40
|
- The use of tags for metadata needs to be enabled under `Advanced Settings`. It is disabled by default.
|
|
41
41
|
- If you decide to use tags, you cannot continue to use old measurements that were gathered with Influx 1.x, as they are stored in fields.
|
|
42
|
-
- Attempting to use an existing database that was
|
|
42
|
+
- Attempting to use an existing database that was set up without enabling the Tag-feature will cause the adapter to fail to initialize, and you will see an error message about it in the log.
|
|
43
43
|
- This also is valid the other way: Once you start using the Tag-feature in a new database, you cannot switch back to using fields for this database.
|
|
44
44
|
- This feature is currently only available, if you use Influx 2.x. And only if you use the new responsive GUI of Admin 5.
|
|
45
45
|
|
|
@@ -57,20 +57,20 @@ Please also read [Understanding Retention Policies](RetentionPolicies.md).
|
|
|
57
57
|
## Direct writes or buffered writes?
|
|
58
58
|
With the default configuration the adapter stores each single datapoint directly into the database and only use the internal buffer if the database is not available. If the database was not available the buffer is flushed at the given interval, so it can take the defined interval till the missing points are written!
|
|
59
59
|
|
|
60
|
-
By changing the configuration it is possible to cache new
|
|
61
|
-
InfluxDB has a limitation of the maximum size for writes which is at around 2MB. It should be
|
|
60
|
+
By changing the configuration it is possible to cache new data points up to a defined count or a defined maximum interval after which all points are stored into the database. This also gives better performance and less system load compared to writing the data points directly.
|
|
61
|
+
InfluxDB has a limitation of the maximum size for writes which is at around 2MB. It should be safe to have up to 15.000 data points as buffer maximum, maybe also 20.000, but this highly depends on the length of your datapoint-IDs.
|
|
62
62
|
|
|
63
|
-
On exit of the adapter the buffer is
|
|
63
|
+
On exit of the adapter the buffer is stored on disk and reinitialized with next adapter start, so no data points should be lost and will be written after next start.
|
|
64
64
|
|
|
65
|
-
## InfluxDB and
|
|
66
|
-
InfluxDB is very strict on
|
|
67
|
-
The adapter tries to write with the correct value, but if the datatype changes for the same state then there may be write
|
|
68
|
-
errors
|
|
65
|
+
## InfluxDB and data types
|
|
66
|
+
InfluxDB is very strict on data types. The datatype for a measurement value is defined with it's first write.
|
|
67
|
+
The adapter tries to write with the correct value, but if the datatype changes for the same state then there may be the write
|
|
68
|
+
errors in the InfluxDB. The adapter detects this and will write these potential conflicting data points always directly, but write errors mean that the value is not written into the DB at all. So make sure to check the logs for such cases.
|
|
69
69
|
|
|
70
|
-
Additionally InfluxDB do not support "null" values, so these are not written at all into the DB.
|
|
70
|
+
Additionally, InfluxDB do not support "null" values, so these are not written at all into the DB.
|
|
71
71
|
|
|
72
72
|
## Installation of InfluxDB
|
|
73
|
-
Please refer to the official InfluxDB pages for
|
|
73
|
+
Please refer to the official InfluxDB pages for installation instructions depending on your OS.
|
|
74
74
|
|
|
75
75
|
* InfluxDB 1.x: https://docs.influxdata.com/influxdb/v1.8/introduction/install/
|
|
76
76
|
* InfluxDB 2.x: https://docs.influxdata.com/influxdb/v2.0/install/
|
|
@@ -78,7 +78,7 @@ Please refer to the official InfluxDB pages for installationinstructions dependi
|
|
|
78
78
|
### Setup authentication for InfluxDB 1.x (optional)
|
|
79
79
|
**NOTE:** Influx DB V2.x relies on organization/token login, instead of username/password! This is only applicable for InfluxDB 1.x
|
|
80
80
|
|
|
81
|
-
If you use DB
|
|
81
|
+
If you use DB locally you may leave authentication disabled and skip this part.
|
|
82
82
|
|
|
83
83
|
- Start service: ``` service influxdb start ```
|
|
84
84
|
- Go to admin page: http://<ip>:8083
|
|
@@ -107,7 +107,7 @@ Enable authentication, by editing /etc/influxdb/influxdb.conf:
|
|
|
107
107
|
There is additional charting tool for InfluxDB - Grafana.
|
|
108
108
|
It must be installed additionally.
|
|
109
109
|
|
|
110
|
-
Install a current version of Grafana 3.x+ because InfluxDB support is enhanced there in
|
|
110
|
+
Install a current version of Grafana 3.x+ because InfluxDB support is enhanced there in comparison to earlier Grafana versions.
|
|
111
111
|
|
|
112
112
|
Under debian you can install it as described at http://docs.grafana.org/installation/debian/ .
|
|
113
113
|
For ARM platforms your can check vor v3.x at https://github.com/fg2it/grafana-on-raspberry.
|
|
@@ -183,7 +183,7 @@ sendTo('influxdb.0', 'query', 'from(bucket: "iobroker") |> range(start: -3h); fr
|
|
|
183
183
|
**NOTE:** The values are coming back in the result array in filename "value" (instead of "val" as normal in ioBroker)
|
|
184
184
|
|
|
185
185
|
## Get history
|
|
186
|
-
Additional to custom queries, you can use build in system function **getHistory** to access the stored history for
|
|
186
|
+
Additional to custom queries, you can use build in system function **getHistory** to access the stored history for data points:
|
|
187
187
|
```
|
|
188
188
|
var end = new Date().getTime();
|
|
189
189
|
sendTo('influxdb.0', 'getHistory', {
|
|
@@ -207,6 +207,7 @@ Possible options:
|
|
|
207
207
|
- **limit** - do not return more entries than limit (only used if aggregate is 'onchange'/'none')
|
|
208
208
|
- **addId** - if *id* field should be included in answer
|
|
209
209
|
- **aggregate** - aggregate method:
|
|
210
|
+
- *minmax* - Splice the whole time range in small intervals and find for every interval max value and min value and use them for this interval (nulls will be ignored).
|
|
210
211
|
- *max* - Splice the whole time range in small intervals and find for every interval max value and use it for this interval (nulls will be ignored).
|
|
211
212
|
- *min* - Same as max, but take minimal value.
|
|
212
213
|
- *average* - Same as max, but take average value.
|
|
@@ -217,9 +218,11 @@ Possible options:
|
|
|
217
218
|
When raw data are selected without using 'step' the returned fields are ts, val, ack, q and from.
|
|
218
219
|
As soon as step is used the returned fields are ts and val.
|
|
219
220
|
|
|
221
|
+
Interpolated values will be marked as `i=true`, like: `{i: true, val: 4.7384845, ts: 29892365723652}`.
|
|
222
|
+
|
|
220
223
|
Please hold in mind that InfluxDB aggregates on "rounded time boundaries" (see https://docs.influxdata.com/influxdb/v0.11/troubleshooting/frequently_encountered_issues/#understanding-the-time-intervals-returned-from-group-by-time-queries)
|
|
221
224
|
|
|
222
|
-
InfluxDB is very strict when it comes to
|
|
225
|
+
InfluxDB is very strict when it comes to data types. This has effects for aggregator functions, e.g.:
|
|
223
226
|
* average (MEAN) can not be used for boolean values (true/false), only MIN or MAX works here
|
|
224
227
|
* average (MEAN) can not be used for string values (text), no aggregator makes sense here at all
|
|
225
228
|
* ...
|
|
@@ -235,11 +238,57 @@ The Message can have one of the following three formats:
|
|
|
235
238
|
* one ID and array of state objects
|
|
236
239
|
* array of multiple IDs with state objects
|
|
237
240
|
|
|
241
|
+
## delete state
|
|
242
|
+
If you want to delete entry from the Database you can use the build in system function **delete**:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
sendTo('sql.0', 'delete', [
|
|
246
|
+
{id: 'mbus.0.counter.xxx', state: {ts: 1589458809352},
|
|
247
|
+
{id: 'mbus.0.counter.yyy', state: {ts: 1589458809353}
|
|
248
|
+
], result => console.log('deleted'));
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
To delete ALL history data for some data point execute:
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
sendTo('sql.0', 'deleteAll', [
|
|
255
|
+
{id: 'mbus.0.counter.xxx'}
|
|
256
|
+
{id: 'mbus.0.counter.yyy'}
|
|
257
|
+
], result => console.log('deleted'));
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
To delete history data for some data point and for some range, execute:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
sendTo('sql.0', 'deleteRange', [
|
|
264
|
+
{id: 'mbus.0.counter.xxx', start: '2019-01-01T00:00:00.000Z', end: '2019-12-31T23:59:59.999'},
|
|
265
|
+
{id: 'mbus.0.counter.yyy', start: 1589458809352, end: 1589458809353}
|
|
266
|
+
], result => console.log('deleted'));
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Time could be ms since epoch or ans string, that could be converted by javascript Date object.
|
|
270
|
+
|
|
271
|
+
Values will be deleted including defined limits. `ts >= start AND ts <= end`
|
|
272
|
+
|
|
273
|
+
## change state
|
|
274
|
+
If you want to change entry's value, quality or acknowledge flag in the database you can use the build in system function **update**:
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
sendTo('sql.0', 'update', [
|
|
278
|
+
{id: 'mbus.0.counter.xxx', state: {ts: 1589458809352, val: 15, ack: true, q: 0},
|
|
279
|
+
{id: 'mbus.0.counter.yyy', state: {ts: 1589458809353, val: 16, ack: true, q: 0}
|
|
280
|
+
], result => console.log('deleted'));
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
`ts` is mandatory. At least one other flags must be included in state object.
|
|
284
|
+
|
|
285
|
+
Be careful with `counters`. The `counters` in DB will not be reset, and you must handle it yourself.
|
|
286
|
+
|
|
238
287
|
## History Logging Management via Javascript
|
|
239
|
-
The adapter supports enabling and disabling of history logging via JavaScript and also retrieving the list of enabled
|
|
288
|
+
The adapter supports enabling and disabling of history logging via JavaScript and also retrieving the list of enabled data points with their settings.
|
|
240
289
|
|
|
241
290
|
### enable
|
|
242
|
-
The message requires to have the "id" of the datapoint.Additionally optional "options" to define the datapoint specific settings:
|
|
291
|
+
The message requires to have the "id" of the datapoint. Additionally, optional "options" to define the datapoint specific settings:
|
|
243
292
|
|
|
244
293
|
```
|
|
245
294
|
sendTo('influxdb.0', 'enableHistory', {
|
|
@@ -257,7 +306,7 @@ sendTo('influxdb.0', 'enableHistory', {
|
|
|
257
306
|
console.log(result.error);
|
|
258
307
|
}
|
|
259
308
|
if (result.success) {
|
|
260
|
-
//
|
|
309
|
+
// successfully enabled
|
|
261
310
|
}
|
|
262
311
|
});
|
|
263
312
|
```
|
|
@@ -273,7 +322,7 @@ sendTo('influxdb.0', 'disableHistory', {
|
|
|
273
322
|
console.log(result.error);
|
|
274
323
|
}
|
|
275
324
|
if (result.success) {
|
|
276
|
-
//
|
|
325
|
+
// successfully enabled
|
|
277
326
|
}
|
|
278
327
|
});
|
|
279
328
|
```
|
|
@@ -304,7 +353,15 @@ sendTo('influxdb.0', 'getEnabledDPs', {}, function (result) {
|
|
|
304
353
|
Placeholder for the next version (at the beginning of the line):
|
|
305
354
|
### __WORK IN PROGRESS__
|
|
306
355
|
-->
|
|
356
|
+
|
|
307
357
|
## Changelog
|
|
358
|
+
### 2.5.2 (2022-02-22)
|
|
359
|
+
* (bluefox) Marked interpolated data with `i=true`
|
|
360
|
+
|
|
361
|
+
### 2.5.0 (2022-02-14)
|
|
362
|
+
* (bluefox) Added new messages: 'update', 'delete', 'deleteRange', 'deleteAll' (only for influxdb v1)
|
|
363
|
+
* (bluefox) Corrected aggregation of data
|
|
364
|
+
|
|
308
365
|
### 2.4.0 (2021-12-19)
|
|
309
366
|
* (Excodibur) Added expert settings to deactivate health checks for Influx 2 db (There are no health checks for Influx 1)
|
|
310
367
|
* (Excodibur) Hide settings not relevant when "log changes only" is not used
|
|
@@ -353,7 +410,7 @@ sendTo('influxdb.0', 'getEnabledDPs', {}, function (result) {
|
|
|
353
410
|
* (bluefox) added command to read supported features
|
|
354
411
|
|
|
355
412
|
### 1.8.6 (2020-05-11)
|
|
356
|
-
* (Apollon77) make sure disabling of
|
|
413
|
+
* (Apollon77) make sure disabling of data points while starting adapter do not crash adapter (Sentry IOBROKER-INFLUXDB-7)
|
|
357
414
|
* (Apollon77) Make sure all start values are processed correctly
|
|
358
415
|
* (Apollon77) More checks to make sure to not crash when states are disabled while data are processed (Sentry IOBROKER-INFLUXDB-8)
|
|
359
416
|
|
|
@@ -361,7 +418,7 @@ sendTo('influxdb.0', 'getEnabledDPs', {}, function (result) {
|
|
|
361
418
|
* (bluefox) set default history if not yet set
|
|
362
419
|
|
|
363
420
|
### 1.8.4 (2020-05-02)
|
|
364
|
-
* (Apollon77) make sure disabling of
|
|
421
|
+
* (Apollon77) make sure disabling of data points do not crash adapter (Sentry IOBROKER-INFLUXDB-4)
|
|
365
422
|
|
|
366
423
|
### 1.8.3 (2020-04-29)
|
|
367
424
|
* (Apollon77) Fix pot crash case when deleting objects while saving values (Sentry)
|
|
@@ -384,7 +441,7 @@ sendTo('influxdb.0', 'getEnabledDPs', {}, function (result) {
|
|
|
384
441
|
* (Apollon77) Small fix for older configurations
|
|
385
442
|
|
|
386
443
|
### 1.3.2
|
|
387
|
-
* (Apollon77) Enhance Min-Delta logic for
|
|
444
|
+
* (Apollon77) Enhance Min-Delta logic for data points from type mixed
|
|
388
445
|
|
|
389
446
|
### 1.3.1 (2017-01-16)
|
|
390
447
|
* (bluefox) Fix handling of float values in Adapter config and Datapoint config.
|
|
@@ -466,7 +523,7 @@ sendTo('influxdb.0', 'getEnabledDPs', {}, function (result) {
|
|
|
466
523
|
|
|
467
524
|
The MIT License (MIT)
|
|
468
525
|
|
|
469
|
-
Copyright (c) 2015-
|
|
526
|
+
Copyright (c) 2015-2022 bluefox, apollon77
|
|
470
527
|
|
|
471
528
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
472
529
|
of this software and associated documentation files (the "Software"), to deal
|
package/io-package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"pl": "Logowanie stanów do InfluxDB",
|
|
14
14
|
"zh-cn": "将状态记录到InfluxDB中"
|
|
15
15
|
},
|
|
16
|
-
"version": "2.
|
|
16
|
+
"version": "2.5.2",
|
|
17
17
|
"title": "Logging data with InfluxDB",
|
|
18
18
|
"titleLang": {
|
|
19
19
|
"en": "Logging data with InfluxDB",
|
|
@@ -28,6 +28,42 @@
|
|
|
28
28
|
"zh-cn": "使用InfluxDB记录数据"
|
|
29
29
|
},
|
|
30
30
|
"news": {
|
|
31
|
+
"2.5.2": {
|
|
32
|
+
"en": "Marked interpolated data with `i=true`",
|
|
33
|
+
"de": "Markierte interpolierte Daten mit `i=true`",
|
|
34
|
+
"ru": "Помеченные интерполированные данные с `i=true`",
|
|
35
|
+
"pt": "Dados interpolados marcados com `i=true`",
|
|
36
|
+
"nl": "Gemarkeerde geïnterpoleerde gegevens met `i=true`",
|
|
37
|
+
"fr": "Données interpolées marquées avec `i=true`",
|
|
38
|
+
"it": "Dati interpolati contrassegnati con `i=true`",
|
|
39
|
+
"es": "Datos interpolados marcados con `i=true`",
|
|
40
|
+
"pl": "Oznaczono dane interpolowane za pomocą `i=true`",
|
|
41
|
+
"zh-cn": "用 `i=true` 标记插值数据"
|
|
42
|
+
},
|
|
43
|
+
"2.5.1": {
|
|
44
|
+
"en": "Marked interpolated data with `i=true`",
|
|
45
|
+
"de": "Markierte interpolierte Daten mit `i=true`",
|
|
46
|
+
"ru": "Помеченные интерполированные данные с `i=true`",
|
|
47
|
+
"pt": "Dados interpolados marcados com `i=true`",
|
|
48
|
+
"nl": "Gemarkeerde geïnterpoleerde gegevens met `i=true`",
|
|
49
|
+
"fr": "Données interpolées marquées avec `i=true`",
|
|
50
|
+
"it": "Dati interpolati contrassegnati con `i=true`",
|
|
51
|
+
"es": "Datos interpolados marcados con `i=true`",
|
|
52
|
+
"pl": "Oznaczono dane interpolowane za pomocą `i=true`",
|
|
53
|
+
"zh-cn": "用 `i=true` 标记插值数据"
|
|
54
|
+
},
|
|
55
|
+
"2.5.0": {
|
|
56
|
+
"en": "Added new messages: 'update', 'delete', 'deleteRange', 'deleteAll' (only for influxdb v1)\nCorrected aggregation of data",
|
|
57
|
+
"de": "Neue Nachrichten hinzugefügt: 'update', 'delete', 'deleteRange', 'deleteAll' (nur für influxdb v1)\nKorrigierte Aggregation von Daten",
|
|
58
|
+
"ru": "Добавлены новые сообщения: 'update', 'delete', 'deleteRange', 'deleteAll' (только для influxdb v1)\nИсправлена агрегация данных",
|
|
59
|
+
"pt": "Adicionadas novas mensagens: 'update', 'delete', 'deleteRange', 'deleteAll' (somente para influxdb v1)\nAgregação de dados corrigida",
|
|
60
|
+
"nl": "Nieuwe berichten toegevoegd: 'update', 'delete', 'deleteRange', 'deleteAll' (alleen voor influxdb v1)\nGecorrigeerde aggregatie van gegevens",
|
|
61
|
+
"fr": "Ajout de nouveaux messages : 'update', 'delete', 'deleteRange', 'deleteAll' (uniquement pour influxdb v1)\nAgrégation corrigée des données",
|
|
62
|
+
"it": "Aggiunti nuovi messaggi: 'update', 'delete', 'deleteRange', 'deleteAll' (solo per influxdb v1)\nAggregazione dei dati corretta",
|
|
63
|
+
"es": "Se agregaron nuevos mensajes: 'actualizar', 'eliminar', 'eliminar rango', 'eliminar todo' (solo para influxdb v1)\nAgregación corregida de datos",
|
|
64
|
+
"pl": "Dodano nowe wiadomości: 'update', 'delete', 'deleteRange', 'deleteAll' (tylko dla influxdb v1)\nPoprawiona agregacja danych",
|
|
65
|
+
"zh-cn": "添加了新消息:'update'、'delete'、'deleteRange'、'deleteAll'(仅适用于 influxdb v1)\n更正的数据聚合"
|
|
66
|
+
},
|
|
31
67
|
"2.4.0": {
|
|
32
68
|
"en": "Added expert settings to deactivate health checks for Influx 2 db (There are no health checks for Influx 1)\nHide settings not relevant when \"log changes only\" is not used\nAllow all number values for debounce again\nInfluxDB also do not like Infinite values, so ignore them too",
|
|
33
69
|
"de": "Experteneinstellungen hinzugefügt, um Gesundheitsprüfungen für Influx 2 db zu deaktivieren (Es gibt keine Gesundheitsprüfungen für Influx 1)\nNicht relevante Einstellungen ausblenden, wenn \"Nur Änderungen protokollieren\" nicht verwendet wird\nAlle Zahlenwerte wieder für die Entprellung zulassen\nInfluxDB mag auch keine unendlichen Werte, also ignoriere sie auch",
|
|
@@ -75,42 +111,6 @@
|
|
|
75
111
|
"es": "IMPORTANTE: ¡El adaptador ahora requiere Admin 5.1.15+ y js-controller 3.3+! Para otras versiones de admin o js-controller, utilice la versión anterior v1.9.5 de este adaptador.\nSe agregó compatibilidad con InfluxDB 2.0\nAjuste el manejo de la retención en el nivel de la base de datos para que funcione con InfluxDB 1.xy 2.x\nSe eliminaron las opciones de retención a nivel de punto de datos porque nunca funcionó y tampoco es realmente compatible con InfluxDB",
|
|
76
112
|
"pl": "WAŻNE: Adapter wymaga teraz Admin 5.1.15+ i js-controller 3.3+! W przypadku innych wersji administratora lub kontrolera js użyj poprzedniej wersji v1.9.5 tego adaptera.\nDodano obsługę InfluxDB 2.0\nDostosuj obsługę przechowywania na poziomie bazy danych, aby działała dla InfluxDB 1.x i 2.x\nUsunięto opcje przechowywania na poziomie punktu danych, ponieważ nigdy nie działały i nie są już obsługiwane przez InfluxDB",
|
|
77
113
|
"zh-cn": "重要提示:适配器现在需要 Admin 5.1.15+ 和 js-controller 3.3+!对于其他 admin 或 js-controller 版本,请使用该适配器以前的 v1.9.5。\n添加了 InfluxDB 2.0 支持\n调整数据库级别的保留处理以适用于 InfluxDB 1.x 和 2.x\n删除了数据点级别的保留选项,因为从来没有工作过,也不再受到 InfluxDB 的真正支持"
|
|
78
|
-
},
|
|
79
|
-
"1.9.5": {
|
|
80
|
-
"en": "Added the support of Admin5",
|
|
81
|
-
"de": "Unterstützung von Admin5 hinzugefügt",
|
|
82
|
-
"ru": "Добавлена поддержка Admin5",
|
|
83
|
-
"pt": "Adicionado o suporte de Admin5",
|
|
84
|
-
"nl": "Ondersteuning toegevoegd van Admin5",
|
|
85
|
-
"fr": "Ajout du support d'Admin5",
|
|
86
|
-
"it": "Aggiunto il supporto di Admin5",
|
|
87
|
-
"es": "Se agregó el soporte de Admin5.",
|
|
88
|
-
"pl": "Dodano obsługę Admin5",
|
|
89
|
-
"zh-cn": "添加了对Admin5的支持"
|
|
90
|
-
},
|
|
91
|
-
"1.9.4": {
|
|
92
|
-
"en": "Optimize stop handling",
|
|
93
|
-
"de": "Optimieren Sie das Stop-Handling",
|
|
94
|
-
"ru": "Оптимизировать обработку остановок",
|
|
95
|
-
"pt": "Otimize o manuseio de parada",
|
|
96
|
-
"nl": "Optimaliseer het afhandelen van stops",
|
|
97
|
-
"fr": "Optimiser la gestion des arrêts",
|
|
98
|
-
"it": "Ottimizza la gestione delle fermate",
|
|
99
|
-
"es": "Optimizar el manejo de paradas",
|
|
100
|
-
"pl": "Zoptymalizuj obsługę zatrzymania",
|
|
101
|
-
"zh-cn": "优化停止处理"
|
|
102
|
-
},
|
|
103
|
-
"1.9.3": {
|
|
104
|
-
"en": "Crash case prevented (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
105
|
-
"de": "Absturz verhindert (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
106
|
-
"ru": "Сбой предотвращен (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
107
|
-
"pt": "Caso de falha impedido (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
108
|
-
"nl": "Crashcase voorkomen (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
109
|
-
"fr": "Crash case évité (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
110
|
-
"it": "Crash case prevenuto (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
111
|
-
"es": "Caso de accidente evitado (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
112
|
-
"pl": "Zapobiegano awariom (Sentry IOBROKER-INFLUXDB-T, IOBROKER-INFLUXDB-Y)",
|
|
113
|
-
"zh-cn": "防止发生崩溃情况(哨兵IOBROKER-INFLUXDB-T,IOBROKER-INFLUXDB-Y)"
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
"mode": "daemon",
|
|
@@ -151,12 +151,6 @@
|
|
|
151
151
|
"icon": "influxdb.png",
|
|
152
152
|
"extIcon": "https://raw.githubusercontent.com/ioBroker/ioBroker.influxdb/master/admin/influxdb.png",
|
|
153
153
|
"type": "storage",
|
|
154
|
-
"config": {
|
|
155
|
-
"minWidth": 570,
|
|
156
|
-
"width ": 435,
|
|
157
|
-
"minHeight": 200,
|
|
158
|
-
"height": 540
|
|
159
|
-
},
|
|
160
154
|
"docs": {
|
|
161
155
|
"de": [
|
|
162
156
|
"docs/de/influxdb.md"
|
|
@@ -172,7 +166,7 @@
|
|
|
172
166
|
"custom": "json"
|
|
173
167
|
},
|
|
174
168
|
"connectionType": "local",
|
|
175
|
-
"dataSource": "
|
|
169
|
+
"dataSource": "push",
|
|
176
170
|
"tier": 1
|
|
177
171
|
},
|
|
178
172
|
"native": {
|
package/lib/Database.js
CHANGED
|
@@ -10,19 +10,20 @@ class Database {
|
|
|
10
10
|
writeSeries(series, callback_error) {}
|
|
11
11
|
writePoints(seriesId, pointsToSend, callback_error) {}
|
|
12
12
|
writePoint(seriesName, values, options, callback_error) {}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
query(query, callback) {}
|
|
15
15
|
|
|
16
16
|
calculateShardGroupDuration(retentionTime) { // in seconds
|
|
17
17
|
// Shard Group Duration according to official Influx recommendations
|
|
18
|
-
if (retentionTime
|
|
18
|
+
if (!retentionTime) {//infinite
|
|
19
19
|
return 604800; // 7 days
|
|
20
|
-
else if (retentionTime < 172800) // < 2 days
|
|
20
|
+
} else if (retentionTime < 172800) {// < 2 days
|
|
21
21
|
return 3600; // 1 hour
|
|
22
|
-
else if (
|
|
22
|
+
} else if (retentionTime >= 172800 && retentionTime <= 7862400) {// >= 2 days, <= 6 months (~182 days)
|
|
23
23
|
return 86400; // 1 day
|
|
24
|
-
else // > 6 months
|
|
24
|
+
} else {// > 6 months
|
|
25
25
|
return 604800; // 7 days
|
|
26
|
+
}
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -25,6 +25,8 @@ class DatabaseInfluxDB1x extends Database{
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
connect () {
|
|
28
|
+
this.log.debug(`Connect InfluxDB1: ${this.protocol}://${this.host}:${this.port} [${this.database}]`);
|
|
29
|
+
|
|
28
30
|
this.connection = influx({
|
|
29
31
|
host: this.host,
|
|
30
32
|
port: this.port, // optional, default 8086
|
|
@@ -46,7 +48,7 @@ class DatabaseInfluxDB1x extends Database{
|
|
|
46
48
|
getRetentionPolicyForDB(dbname, callback) {
|
|
47
49
|
this.connection.query('SHOW RETENTION POLICIES ON ' + dbname, (err, rows) => {
|
|
48
50
|
if(err){
|
|
49
|
-
this.log.error(
|
|
51
|
+
this.log.error(`Error retrieving retention policy: ${err}`);
|
|
50
52
|
callback(err, null);
|
|
51
53
|
} else {
|
|
52
54
|
const regex = /(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?/;
|
|
@@ -61,36 +63,35 @@ class DatabaseInfluxDB1x extends Database{
|
|
|
61
63
|
retentionName = row.name;
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
|
-
callback(null, {
|
|
66
|
+
callback(null, {name: retentionName, time: retentionTime});
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
async applyRetentionPolicyToDB(dbname, retention, callback) {
|
|
70
72
|
this.getRetentionPolicyForDB(dbname, (err, oldRetention) => {
|
|
71
|
-
//Check, if there was an error
|
|
73
|
+
// Check, if there was an error
|
|
72
74
|
if (err) {
|
|
73
|
-
callback(err);
|
|
74
|
-
return;
|
|
75
|
+
return callback(err);
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
//Check, if it needs to be changed, otherwise skip
|
|
78
|
-
this.log.debug(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return;
|
|
79
|
+
this.log.debug(`old retention: ${JSON.stringify(oldRetention)} new retention: ${retention}`);
|
|
80
|
+
|
|
81
|
+
if (oldRetention.time !== null && oldRetention.time === parseInt(retention, 10)) {
|
|
82
|
+
this.log.debug(`Retention policy for ${dbname} remains unchanged.`);
|
|
83
|
+
return callback(false);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
const shardDuration = this.calculateShardGroupDuration(retention);
|
|
86
87
|
|
|
87
|
-
//Get name of currently active default policy first, to update only it.
|
|
88
|
+
// Get name of currently active default policy first, to update only it.
|
|
88
89
|
|
|
89
|
-
const command =
|
|
90
|
-
const retentionName =
|
|
90
|
+
const command = oldRetention.time ? 'ALTER' : 'CREATE';
|
|
91
|
+
const retentionName = oldRetention.name ? oldRetention.name : 'global';
|
|
91
92
|
|
|
92
|
-
this.log.info(
|
|
93
|
-
this.connection.query(command
|
|
93
|
+
this.log.info(`Applying retention policy (${retentionName}) for ${dbname} to ${retention === 0 ? 'infinity' : retention + ' seconds'}. Shard Duration: ${shardDuration} seconds`);
|
|
94
|
+
this.connection.query(`${command} RETENTION POLICY "${retentionName}" ON ${dbname} DURATION ${retention}s REPLICATION 1 SHARD DURATION ${shardDuration}s DEFAULT`, callback);
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -115,7 +116,7 @@ class DatabaseInfluxDB1x extends Database{
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
query(query, callback) {
|
|
118
|
-
this.log.debug(
|
|
119
|
+
this.log.debug(`Query to execute: ${query}`);
|
|
119
120
|
this.connection.query(query, callback);
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -127,4 +128,4 @@ class DatabaseInfluxDB1x extends Database{
|
|
|
127
128
|
|
|
128
129
|
module.exports = {
|
|
129
130
|
DatabaseInfluxDB1x : DatabaseInfluxDB1x
|
|
130
|
-
|
|
131
|
+
};
|