Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8e8bf53
Migrate to typescript
GermanBluefox Sep 12, 2025
428bde0
Migrate to typescript
GermanBluefox Sep 12, 2025
0b12ce0
Added docker
GermanBluefox Sep 12, 2025
93dad57
Added self-docker
GermanBluefox Sep 12, 2025
392ce8b
Updated readme
GermanBluefox Sep 12, 2025
51f004d
Remove tgz
GermanBluefox Sep 12, 2025
583a464
Add node 24 for tests
GermanBluefox Sep 12, 2025
8313d29
Remove warnings
GermanBluefox Sep 12, 2025
0f7a970
Change main entry point to build/main.js
GermanBluefox Sep 13, 2025
e61b076
Remove build:lang script from package.json
GermanBluefox Sep 13, 2025
a151593
Add build step after npm install in workflow
GermanBluefox Sep 13, 2025
89a34bc
Added docker monitoring
GermanBluefox Sep 13, 2025
84c865c
Fixing tim in influxdbv1
GermanBluefox Sep 14, 2025
711cd25
Fixing tests
GermanBluefox Sep 14, 2025
37a5645
Formatting
GermanBluefox Sep 14, 2025
708eddb
Fixing tests for V1
GermanBluefox Sep 14, 2025
b016004
Fixing tests for V1
GermanBluefox Sep 14, 2025
faf4344
Fixing tests for V1
GermanBluefox Sep 14, 2025
bccd1ef
Fixing async
GermanBluefox Sep 14, 2025
fad1980
Fixing tests for V2
GermanBluefox Sep 14, 2025
0da2586
Fixing tests for V2
GermanBluefox Sep 15, 2025
4a2bec0
Fixing tests for V2
GermanBluefox Sep 15, 2025
04da2c4
Fixing tests for V2
GermanBluefox Sep 15, 2025
f364ad7
Rename tests
GermanBluefox Sep 15, 2025
2b02742
Rename tests
GermanBluefox Sep 15, 2025
b1d75dd
Fix tests
GermanBluefox Sep 15, 2025
4ec692d
Fix tests
GermanBluefox Sep 15, 2025
9c41f41
Update influx adapter state key in testAdapter.js
GermanBluefox Sep 15, 2025
1d20cac
Update influx adapter state key in test
GermanBluefox Sep 15, 2025
1817749
Update state key for influxdb adapter check
GermanBluefox Sep 15, 2025
2df9c28
Update influx adapter key in testAdapterTags
GermanBluefox Sep 15, 2025
8b4ce91
Fix tests
GermanBluefox Sep 16, 2025
10d07a3
Fix tests
GermanBluefox Sep 16, 2025
f8e179a
Fix tests
GermanBluefox Sep 16, 2025
8fe6cc8
Fix tests
GermanBluefox Sep 16, 2025
d4e4c9c
Working on docker
GermanBluefox Sep 17, 2025
7955602
Working on grafana integration
GermanBluefox Sep 17, 2025
8e839d6
Working on grafana integration
GermanBluefox Sep 17, 2025
c4af634
Working on grafana integration
GermanBluefox Sep 17, 2025
4984bf8
Working on grafana integration
GermanBluefox Sep 21, 2025
8a6538c
Lazy loading of tar-fs
GermanBluefox Sep 24, 2025
4b22f1d
Lazy loading of tar-fs
GermanBluefox Sep 24, 2025
9acb69a
Formatting
GermanBluefox Sep 24, 2025
304a5fa
use plugin-docker
GermanBluefox Sep 26, 2025
770a67b
Fixed docker influxdb
GermanBluefox Oct 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 22.x


- name: Install Dependencies
Expand All @@ -61,7 +57,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand All @@ -72,7 +68,9 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm ci
run: |
npm ci
npm run build

- name: Install Influxdb 1.x (Linux)
if: startsWith(runner.OS, 'linux')
Expand Down Expand Up @@ -102,7 +100,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [20.x, 22.x, 24.x]
os: [ubuntu-latest]

steps:
Expand All @@ -113,7 +111,9 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm ci
run: |
npm ci
npm run build

- name: Install Influxdb 2.x (Linux)
id: influxdb2
Expand Down Expand Up @@ -160,18 +160,15 @@ jobs:
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 22.x

- name: Extract the version and commit body from the tag
id: extract_release
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ node_modules
.idea
exe
/tmp
/build/
*.tgz
5 changes: 4 additions & 1 deletion .releaseconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"plugins": ["iobroker", "license"]
"plugins": ["iobroker", "license"],
"exec": {
"before_commit": "npm run build"
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016-2024 bluefox <dogafox@gmail.com>, apollon77
Copyright (c) 2016-2025 bluefox <dogafox@gmail.com>, apollon77

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ CREATE USER "user" WITH PASSWORD '<userpassword>'
CREATE DATABASE "iobroker"
GRANT ALL ON "iobroker" TO "user"
```

Enable authentication by editing /etc/influxdb/influxdb.conf:
```
[http]
Expand All @@ -105,6 +106,12 @@ Enable authentication by editing /etc/influxdb/influxdb.conf:
```
- Restart service: ``` service influxdb restart ```

## Self-hosted docker image for InfluxDB
This version of the adapter could start a self-hosted docker image of InfluxDB 2.x.
It is not opened for the network and only accessible from localhost. Of course, the docker environment must be installed and running on the host.

The `iobroker` user must have access to the docker CLI. To fix the rights start `iob fix`.

## Installation of Grafana (Charting Tool)
There is an additional charting tool for InfluxDB - Grafana.
It must be installed additionally.
Expand Down Expand Up @@ -375,10 +382,9 @@ sendTo('influxdb.0', 'update', [
If you want to flush the buffers for one or all data points to the Database, you can use the build in system function `flushBuffer`:

```javascript
sendTo('influxdb.0', 'flushBuffer', {id: 'mbus.0.counter.xxx'
, result => console.log('deleted, error: ' + result.error));
sendTo('influxdb.0', 'flushBuffer', {id: 'mbus.0.counter.xxx'}, result => console.log('deleted, error: ' + result.error));
```
if no id is provided all buffers will be flushed.
if no id is provided, all buffers will be flushed.

## History Logging Management via Javascript
The adapter supports enabling and disabling of history logging via JavaScript and also retrieving the list of enabled data points with their settings.
Expand Down Expand Up @@ -707,7 +713,7 @@ sendTo('influxdb.0', 'getEnabledDPs', {}, function (result) {

The MIT License (MIT)

Copyright (c) 2015-2024 bluefox, apollon77
Copyright (c) 2015-2025 bluefox, apollon77

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
45 changes: 23 additions & 22 deletions RetentionPolicies.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
# Understanding retention policies

It is important to understand how **Retention Policies** and **Shard Group Durations** are related in order to determine how long data will be kept in InfluxDB.
It is important to understand how **Retention Policies** and **Shard Group Durations** are related in order to determine how long data
will be kept in InfluxDB.



Influx stores all measurements within a given time range into the same **Shard** which itself is part of a **Shard Group**. The Shard Group enforces a time range defined by `Shard Group Duration` to all shards, but it is set differently depending on the Influx release.
Influx stores all measurements within a given time range into the same **Shard** which itself is part of a **Shard Group**.
The Shard Group enforces a time range defined by `Shard Group Duration` to all shards, but it is set differently depending on the Influx release.

When exceeding the configured `Shard Group Duration`,

- a new Shard is created which stores newer measurement data from that point onwards
- the old Shard with all its measurement-data is still kept in the database, but will be dropped, once the retention policy for the measurement is exceeded


Measurement data-points are not deleted by Influx via "looking" at their retention policies individually, but instead the Shard as a whole is subject to retention policy check and will be dropped, if the retention policy is exceeded. The check however will only be performed on old Shards, meaning Shards that are still active are not checked, as they also still can receive new measurement data points.

*Please refer to https://docs.influxdata.com/influxdb/v1.4/concepts/schema_and_data_layout/#shard-group-duration-management for more explanation and examples.*
*Please refer to https://docs.influxdata.com/influxdb/v1.4/concepts/schema_and_data_layout/#shard-group-duration-management
for more explanation and examples.*

The following two examples illustrate how the same retention period will be enforced differently, depeding on the configured Shard Group Duration.
The following two examples illustrate how the same retention period will be enforced differently, depending on the configured Shard Group Duration.

| | Example 1 | Example 2 |
|--|--|--|
| Retention Period | 2 hours | 2 hours |
| Shard Group Duration | 1 hour | 1 day |
| How long will data be kept at max? | 2 hours | 1 day |
| Why? | The Shard is switched every hour, hence Influx will enforce the configured RP once **every hour** and keep only data from the **last 2 hours**. | The Shard is switched once a day, and Influx will then enforce the configured RP, meaning it will only keep data from the last **2 hours**. Because of this, measurement-data inserted at the beginning of the Shard-lifetime in theory should only be kept for 2 hours, but effectively will be kept a **whole day**. |
| | Example 1 | Example 2 |
|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Retention Period | 2 hours | 2 hours |
| Shard Group Duration | 1 hour | 1 day |
| How long will data be kept at max? | 2 hours | 1 day |
| Why? | The Shard is switched every hour, hence Influx will enforce the configured RP once **every hour** and keep only data from the **last 2 hours**. | The Shard is switched once a day, and Influx will then enforce the configured RP, meaning it will only keep data from the last **2 hours**. Because of this, measurement-data inserted at the beginning of the Shard-lifetime in theory should only be kept for 2 hours, but effectively will be kept a **whole day**. |

## iobroker.influxdb Adapter
The Influx Adapter only allows you to select a **Retention Period** and itself will automatically choose the **Shard Group Duration** according to [official InfluxDB recommendations](https://docs.influxdata.com/influxdb/v2.0/reference/internals/shards/#shard-group-duration).

| Bucket retention period | Default shard group duration |
|--|--|
| less than 2 days | 1h |
| between 2 days and 6 months | 1d |
| greater than 6 months |7d |
| Bucket retention period | Default shard group duration |
|-----------------------------|------------------------------|
| less than 2 days | 1h |
| between 2 days and 6 months | 1d |
| greater than 6 months | 7d |


The Shard Group Duration can still be altered manually in the DB itself, but in order to keep the adapter configuration manageable, it can not be changed directly within ioBroker.
The Shard Group Duration can still be altered manually in the DB itself, but in order to keep the adapter configuration manageable,
it can not be changed directly within ioBroker.

By design the adapter enforces only one global retention policy that applies to all measurements - regardless of the DB version that is used. The policy can be changed at any time, but for the reasons described earlier it might take a while for the changes to take effect.
By design, the adapter enforces only one global retention policy that applies to all measurements - regardless of the DB version that is used. The policy can be changed at any time, but for the reasons described earlier, it might take a while for the changes to take effect.

## Additional considerations

- The shard group duration is often configured shorter than the retention period, in order to be enforced effectively. But it is difficult to state this as a general advice, since other factors, like performance should be considered, too. If shard group durations are configured extremely short, this might be beneficial for housekeeping, but it could negatively impact performance, like causing longer query times, or slow write speeds.
- A retention policy may not be lower than 1 hour. This was a choice made by Influx devs (https://github.com/influxdata/influxdb/issues/5198#issuecomment-166629531) and can only be bypassed by building InfluxDB from latest source with changed values directly.
- Retention policies are checked by default every 30 minutes. This can be changed however in [server configuration for Influx 1.x](https://docs.influxdata.com/influxdb/v1.8/administration/config/#retention-policy-settings) and [server configuration for Influx 2.x](https://docs.influxdata.com/influxdb/v2.0/reference/config-options/#storage-retention-check-interval). This does **not** bypass the principles explained earlier.
- A retention policy may not be lower than 1 hour. This was a choice made by Influx devs (https://github.com/influxdata/influxdb/issues/5198#issuecomment-166629531) and can only be bypassed by building InfluxDB from the latest source with changed values directly.
- Retention policies are checked by default every 30 minutes. This can be changed, however, in [server configuration for Influx 1.x](https://docs.influxdata.com/influxdb/v1.8/administration/config/#retention-policy-settings) and [server configuration for Influx 2.x](https://docs.influxdata.com/influxdb/v2.0/reference/config-options/#storage-retention-check-interval). This does **not** bypass the principles explained earlier.
- **Influx 1.x**: For existing dbs the adapter is able to detect the current default retention policy and will update it. If you modified retention policies manually and now are still experiencing missing data in the adapter, it might be related to the changed default-policy. See also here for more information: https://docs.influxdata.com/influxdb/v1.7/troubleshooting/frequently-asked-questions/#why-am-i-missing-data-after-creating-a-new-default-retention-policy.
Loading
Loading