Influxdb persistence policy change

I’ve had an issue for about a week now after i updated everything on my server (running oh2 and influxdb 1.0)

After upgrading, I noticed when I searched my db, none of my measurements were being returned… but logging in OH2 seemed to indicate no problems. Looking deeper, I noticed the addition of an “autogen” retention policy.

It’s been a while since I upgraded to 1.x influx with OH … but i recall setting up a retention policy as part of the new process, but everything was on the influx side, not OH’s config files. The result seemed to be I could search for my measurements without a retention policy specified (so maybe none was applied) …

but now my data seems split accross “no retention policy” and “autogen” policy.

Any ideas why this suddenly hit me? and any ideas how I should proceed forward? Ideally measurements from before this upgrade to after could be accessible by the same query so they get graphed together.

InfluxDB changed its default retentionpolicy from name “default” to “autogen”. Openhab does reflect that. In order to write to the old one, you need to set the retentionpolicy in OH to “default”.
Having data already split up in two of those policies you may look at the following post from @ThomDietrich , where he describes how to copy data from one policy to another. [](

In addition to @opus’s response, I will mention that I too had originally started with an older version of InfluxDB and upgraded to 1.x (I have no idea when, I run it in a Docker container using the official default image and I have everything automatically update).

Anyway, there was a recent change to the add-on to support custom created retention policies so you can create a policy that auto-deletes data as it ages. However, this means if you have a DB created with an older InfluxDB the default retention policy is named “default” while the default retention policy for 1.x is “autogen”. So, if you have a DB created before when it used “default” you need to add a retentionPolicy=default to the influxdb.cfg.

Also, I discovered in my setup that some (maybe all?) of the persistence calls, in particular maximumSince and minimumSince, fail with this new add-on with a syntax error on the query (see the bottom of the Influx+Grafana Tutorial thread).

Thanks guys – attempted to use “default” retention policy with “retentionPolicy=default”, but OH throws the following exception:

[org.eclipse.smarthome.core.persistence.manager(94)] The addPersistenceService method has thrown an exception
java.lang.RuntimeException: {"error":"error parsing query: found DEFAULT, expected identifier at line 1, char 19"}

I know the retention policy is in influx:

when the influx bundle starts up, i can see it running the following querries with “default” appended to the start of the measurement:

query string: select value from default.VAR_Verona_Sunrise ORDER BY time DESC limit 1

but if I run this on influx side, nothing returns … I only get my older data if I leave that rp preface empty. But if I don’t specify one in OH, “autogen” is appended. Should i just move all my prior data to one of these retention policies?

I’m currently working through the same problem with @theo here:

Problem with retention policy of influxdb has been fixed in a PR I just made..

Until it is merged, you can build the PR yourself and place the generated .jar in the addons directory.

Seems to work fine in openhab2 at the moment. It should also fix problems where names of items contain special characters.

The problem was indeed caused by improper (no) escaping or quoting of the retention policy and item name.

I also reviewed the rest of the query generation and it seems the other parts will not exhibit similar behaviour.