[SOLVED] Persistence with InfluxDB not storing data?

Tags: #<Tag:0x00007f2fb1e45038> #<Tag:0x00007f2fb1e44e58>
  • Platform information:
    • Hardware: 64-bit 4 cores/2GB RAM/128GB HDD (This is actually a virtual machine, but these are the specs it’s been dealt)
    • OS: Debian Stretch (9.5)
    • Java Runtime Environment: Zulu 8.31.0.1-linux64
    • openHAB version: 2.3.0

I’m trying to configure persistence with InfluxDB but it doesn’t seem to be storing any data. I got inspired by [InfluxDB+Grafana persistence and graphing] but I’ve already got a InfluxDB/Grafana setup on another host already so I wanted to use that. I set up a separate db and user for openHAB. I verified that they work using Grafana.

/etc/openhab2/services/influxdb.cfg:
# The database URL, e.g. http://127.0.0.1:8086 or https://127.0.0.1:8084 .
# Defaults to: http://127.0.0.1:8086
url=http://<influxdb host ip>:8086

# The name of the database user, e.g. openhab.
# Defaults to: openhab
user=openhab

# The password of the database user.
password=<myverysecretpassword>

# The name of the database, e.g. openhab.
# Defaults to: openhab
db=openhab

# Retention policy
retentionPolicy=autogen

/etc/openhab2/persistence/influxdb.persist:
Strategies {
        everyHour : "0 0 * * * ?"
        everyDay  : "0 0 0 * * ?"

        // if no strategy is specified for an Item entry below, the default list will be used
       default = everyChange

}

Items {
    rfxcom_*   : strategy = everyChange, restoreOnStartup
    zwave_*    : strategy = everyChange, everyHour
}

In the logs, even with DEBUG, all that I can ever find about persistence is this during startup:

2018-09-02 19:42:33.236 [DEBUG] [.InfluxDBPersistenceServiceActivator] - InfluxDB persistence bundle has been started.
2018-09-02 19:42:33.237 [DEBUG] [org.openhab.persistence.influxdb    ] - BundleEvent STARTED - org.openhab.persistence.influxdb
2018-09-02 19:42:33.269 [DEBUG] [.internal.InfluxDBPersistenceService] - influxdb persistence service activated
2018-09-02 19:42:33.445 [DEBUG] [.internal.InfluxDBPersistenceService] - database status is OK, version is 1.3.1
2018-09-02 19:42:33.517 [DEBUG] [org.openhab.persistence.influxdb    ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService, org.openhab.core.persistence.QueryablePersistenceService}={service.id=342, service.bundleid=215, service.scope=bundle, user=openhab, url=http://<influxdb host ip>:8086, component.name=org.openhab.persistence.influxdb, component.id=221, password=<myverysecretpassword>, retentionPolicy=autogen, service.pid=org.openhab.influxdb, db=openhab} - org.openhab.persistence.influxdb

I also set influxdb as the default persistence in Paper UI -> Configuration -> System
Any ideas? :slight_smile:

Do you have a group item named rfxcom_? because the meaning of rfxcom_* in the persist-file is:
“Take all members of this group and persist them with following strrategies.”
In other words rfxcom_ is the exact name of the group, which members should be persisted. The group item itself will not be persisted.

1 Like

Oh! I thought that was just a way to wildcard any item names! :exploding_head: I’ll try replacing those with exact item names instead. But shouldn’t the “default” line in Strategies make every item persist if they are not defined in Items (in influxdb.persist)? Or is that another misunderstanding from my side?

No, default is the default strategy.

Strategies {
        everyHour : "0 0 * * * ?"  //self defined strategies
        everyDay  : "0 0 0 * * ?"

        // if no strategy is specified for an Item entry below, the default list will be used
       default = everyChange

}

Items {
    group*     : strategy = everyChange, restoreOnStartup //persist all direct members of the group 'group'
    item       : strategy = everyChange, everyHour // persist the item 'item'
    otherItem     // no strategy set, so use default strategy for item 'otherItem'
    *          : strategy = everyChange   // persist every item
}
1 Like

Thank you Mr. Hartmann! I just got my first values in the db :slight_smile:
Now I think I understand the default as well. That’s very useful. Have a nice evening! :slight_smile:

Hello,
I have a very similar problem with storing openhab data in influx. On my Synology, I installed influxdb, grafana and OH binding.
The openhab settings are almost exactly the same as malgoe posted at the beginning of this blog. The only difference is: I don’t use a group item, but a simple item tracking a temperature every minute. I checked all spellings several times - seems to be ok.When I SSH to influx console it shows the following:

use openhab
Using database openhab
auth
username: openhab
password:
settings
Setting Value


Host localhost:8086
Username openhab
Database openhab
RetentionPolicy
Pretty false
Format column
Write Consistency all
Chunked true
Chunk Size 0

SHOW series
SHOW measurements

Seems. that influx knows the DB openhab and the user (I checked it in the Web GUI of influx, too - its ok.). But no series, no measurements … I use in parallel rrd4j, there the item record is ok.
Any idea, what’s going wrong?

Hello, @uUlrich

Please use the code fences when posting any sot of code. Normal text is hard to read for code.

You haven’t provided use with your openHAB configuration for Influx
Can you post your influxdb.cfg and your influxdb.persist files, please

In the future please refer to: How to ask a good question / Help Us Help You

It is recommended to open a new thread and refer to the old one in your first post.
Thanks

Hello Vincent, sorry for my mistake. Here are the codes - I hope it works

influxdb.cfg

url=http://192.168.178.38:8086
user=openhab
password=<mypw>
db=openhab
retentionPolicy=autogen

influxdb.persist

Strategies {
        everyMinute : "0 * * * * ?"
        everyHour : "0 0 * * * ?"
        everyDay  : "0 0 0 * * ?"

        // if no strategy is specified for an Item entry below, the default list will be used
       default = everyMinute
           }
Items {
       FRITZDECT2001_Power: strategy = everyMinute, restoreOnStartup
    }

Looks OK. Did you restart OH since setting it up?

Yes, even several times

What do the logs show about influx when you start OH?

Just tried to start the debugger in Visual Studion Code,—> error “Die Laufzeit ‘node’ wurde in PATH nicht gefunden. " When using KARAF, I cannot execute comman log:set DEBUG --> Error executing command: Unrecognized configuration”. Seems I have to fight with the debugger first…

In VSCode there is no debugger active for openHAB yet :slight_smile: but I think you don’t need it as openHAB does online code checking.
In question of logs: Please take a look at /var/log/openhab2/openhab.log. There should be some lines about influxDB persistence Service.
You can set the log level for influxDB by using the karaf console:

log:set DEBUG org.openhab.persistence.influxdb

the default level would be

log:set DEFAULT org.openhab.persistence.influxdb

There is also a TRACE level if DEBUG will not suffice.

Thanks for the hint that VSC has no OH debugger. Unfortunately, in the openhab.log file there a no lines at all! I set up OH 2.3.0 completely from scratch, with the same result. My OH items and rules should generate a whole bunch of events - but nothing is logged. Seems that the general logging level is just ERROR, and I don’t know how to switch to a higher level.
I tried the log:set command in KARAF. I can enter the log subshell, but for the set command you proposed I get “error executing command: Unrecognized configuration”.
At the moment, I am not able to generate any debug infos. What can I do?
Thanks for your help.

In addition to my former reply: log:list works. Here is a short snippet of the list answer which shows influxdb persistence running:

238 │ Active   │  80 │ 2.3.0                  │ Homematic Binding
240 │ Active   │  80 │ 1.12.0                 │ openHAB InfluxDB Persistence bundle
openhab> set DEBUG org.openhab.persistence.influxdb
Error executing command: Unrecognized configuration
openhab>

maybe, it helps…

Sorry for bothering you again.
I found an entry in …org.apache.karaf.shell.cfg where a debug level can be changed. I am not sure whether this is the right place, but I changed it to level=3 (debug). After restarting my Synology (!!! just restarting openhab changed nothing) I found the following entries in openhab.log

2018-12-16 20:48:23.852 [INFO] [org.apache.karaf.main.lock.SimpleFileLock] - Trying to lock /volume1/SmartHome/openHAB/userdata/tmp/lock
2018-12-16 20:48:23.855 [INFO] [org.apache.karaf.main.lock.SimpleFileLock] - Lock acquired
2018-12-16 20:48:23.856 [INFO] [org.apache.karaf.main.Main] - Lock acquired. Setting startlevel to 100

What does it mean “trying to lock…” What does mean “startlevel 100”… No idea

Please don’t touch files that you don’t know!

It’s really simple to set the debug level, as said in [SOLVED] Persistence with InfluxDB not storing data?

The command is

log:set DEBUG org.openhab.persistence.influxdb

don’t omit log, and don’t use a subshell.

How to get the correct path: (I have made a complete ‘screenshot’ via text clipboard. The console input is only after openhab>)

openhabian@openhab2:~$ openhab-cli console

Logging in as openhab

                          __  _____    ____
  ____  ____  ___  ____  / / / /   |  / __ )
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  |
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/
    /_/                        2.5.0-SNAPSHOT
                               Build #1466

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB.

openhab> feature:list | grep flux
openhab-persistence-influxdb                x 1.14.0.SNAPSHOT  x x        x Started     x openhab-addons-2.5.0-SNAPSH                                              OT        x InfluxDB (v 1.0) Persistence
openhab> feature:info openhab-persistence-influxdb
Feature openhab-persistence-influxdb 1.14.0.SNAPSHOT
Description:
  InfluxDB (v 1.0) Persistence
Feature has no configuration
Feature configuration files:
  ${openhab.conf}/services/influxdb.cfg
Feature depends on:
  openhab-runtime-base 0.0.0
  openhab-runtime-compat1x 0.0.0
Feature contains followed bundles:
  mvn:org.openhab.persistence/org.openhab.persistence.influxdb/1.14.0-SNAPSHOT start-level=80
Feature has no conditionals.
openhab> log:set DEBUG org.openhab.persistence.influxdb
openhab> log:list
Logger                                             │ Level
───────────────────────────────────────────────────┼────────
ROOT                                               │ WARN
javax.jmdns                                        │ ERROR
org.apache.karaf.jaas.modules.audit                │ INFO
org.apache.karaf.kar.internal.KarServiceImpl       │ ERROR
org.apache.karaf.shell.support                     │ OFF
org.apache.sshd                                    │ WARN
org.eclipse.jetty.util.thread.ThreadPoolBudget     │ ERROR
org.eclipse.smarthome                              │ INFO
org.jupnp                                          │ ERROR
org.openhab                                        │ INFO
org.openhab.persistence.influxdb                   │ DEBUG
org.ops4j.pax.url.mvn.internal.AetherBasedResolver │ ERROR
org.ops4j.pax.web.pax-web-runtime                  │ OFF
smarthome.event                                    │ INFO
smarthome.event.InboxUpdatedEvent                  │ ERROR
smarthome.event.ItemAddedEvent                     │ ERROR
smarthome.event.ItemRemovedEvent                   │ ERROR
smarthome.event.ItemStateEvent                     │ ERROR
smarthome.event.ThingAddedEvent                    │ ERROR
smarthome.event.ThingRemovedEvent                  │ ERROR
smarthome.event.ThingStatusInfoEvent               │ ERROR

Sorry, I posted my reply accidentally to a new link:
https://community.openhab.org/badges/14/first-link?username=uulrich