Openhab not speaking to influxdb...how to test?

I’ve mostly followed the Influxdb+grafana mega thread but used the installer from openhab config tool. Grafana seems to be connected to influxdb, but I don’t seem to be getting any data from openhab into influxdb.

I installed the influxdb binding and it appears there are no settings in paperUI. I created influxdb.persist file. Here are the contents:

Strategies {
everyMinute : "0 * * * * ?"
everyHour   : "0 0 * * * ?"
everyDay    : "0 0 0 * * ?"
default = everyChange
}

Items {
    GardenSensor1_Temperature : strategy = everyChange
    GardenSensor1* : strategy = everyChange
}

I don’t see any errors in the logs. Is there anything I can do to debug or test the connection between openhab and influxdb?

1 Like

try to install chrongraf you will get a bigger picture…

did you create a DB on Influx? i think there is a step of creating a DB in the console

Yea, I did create the database “openhab_db”. Grafana can connect to it, but it’s currently empty.

what about services/influxdb.cfg . can you paste it?

@Gad_Ofir Here’s my cfg file:

url=http://localhost:8086
user=openhab
password=myPassword
db=openhab_db
retentionPolicy=autogen

the only diffrance i see from my config is the
http://localhost:8086
me
url=http://127.0.0.1:8086

it looks ok but maybe try

1 Like

I’m trying 127.0.0.1

@Gad_Ofir I think that did it! For items, the wildcard GardenSensor1* isn’t working, but GardenSensor1_Temperature is working.

1 Like

That’s not a wildcard for persistence. That’s a group name. See persistence in the Items section:

“Note that * is NOT a wildcard match character in this context.”

2 Likes

Thanks for the clarification. I need to make an item group!

By the way for anyone in the future looking at this, another good place to look is the /var/log/syslog if running on a Linux system. With the default influxdb.conf file, it will log an entry every time a write request comes along for the database. So check when an Item changes, then look at the corresponding time in the syslog. This helps break the problem in half. If you see nothing in syslog, then you know your problem is on the OH side as it isn’t getting there. I suspect this is what you’ll find in your case before you switched to the IP address. But if the writes to the database are successful, then you know the OH side is good, and perhaps your query such as from Grafana is incorrect.

1 Like

glad i can help :upside_down_face:

Now to figure out how to get the chart And meters into a sitemap…

Big +1 to this thread, I was struggling to figure out why my data wasn’t persisting. This was the final piece of the puzzle.

I made a few mistakes and did a few tests prior to getting to this point. I’m documenting them here in case someone else needs them:

  • I incorrectly named my persistence file influx.persist, it should be influxdb.persist

  • I verified I could log into Influx with the user I created for OpenHAB

    $ influx -username 'openhab' -password ''
    > use openhab
    

    (it will throw an error if the user can’t be authenticated or has the wrong permission set)

  • I set up a temporary persistence rule to store a sensor’s data every minute, so that I’d have data coming in.

  • I verified in /var/log/syslog that something was being sent every minute, and that it got an “ok” response.

    $ tail /var/log/syslog
    ... influxd[xxx]: [httpd] ...
    
  • I made sure that url in services/influxdb.cfg matched the bind-address in /etc/influxdb/influxdb.conf (the solution raised in this thread, probably 127.0.0.1:8086)

Thanks @Gad_Ofir and @gismofx.

3 Likes

Well As I strugled with this as well heare is my full configuration.

Running openHAB 3.4.0 (Docker)

Please do not copy this directly as this will store way to much data into your database, but you will be able to test your DB input.

File location:
openhab/conf/persistence

influxdb.persist

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
}
Items {
* : strategy = everyChange, everyMinute, restoreOnStartup
}

DB: INfluxdb on a seperated server and I’m using an acces key.