InfluxDB+Grafana persistence and graphing

@theo, @opus,

Before I submit an issue I wanted to make sure the problem isn’t me.

I just upgraded my Influx binding (running 1.9.0.201611090213)

I’ve added retentionPolicy=default to influxdb.cfg.

Everything seems to be working except calls to maximumSince and minimumSince (there may be other persistence methods with problems too). the error I’m seeing is:

2016-11-10 12:50:31.642 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Update max and min temperatures': {"error":"error parsing query: found DEFAULT, expected identifier at line 1, char 19"}

Am I missing something I should have done or is this a bug?

Depending on the version of InfluxDB ( I believe above 1.x) it should be “autogen”. However, if you have other calls to the DB that work the error should be within that rule

I am running InfluxDB 1.0.2 but when I upgraded all of my bindings it was using “autogen” by default and throwing all sorts of errors. Based on the comments above I added the “default” which is what shows up in Grafana. It is saving values without any problem when I use “default”. It is just failing on the calls to maximumSince.

I’m not sure what version of Influx I was using when I first started. Once or twice a week I pull down the latest official Docker image so it is perfectly possible that I started before “autogen” became the “default”.

According to @Theo in #113 “default” should be used on versions before 1.0.

Since I’m no expert in InfluxDB (my knowledge runs back about 21d, as you can see in this thread), I can only guess.

As I understand you have a running DB, which was created possibly on an earlier version, hence the need for “Default”.
You are getting errors when calling “Maximum since”, what is the Syntax you are using to get that?
The error shown states a string “DEFAULT” , however your .cfg is set to “default”, where is the “DEFAULT” UpperCase! coming from?

1 Like
        val startOfDay = now.withTimeAtStartOfDay
        postUpdate(Weather_Temp_Max, Weather_Temperature.maximumSince(startOfDay, "influxdb").state)
        postUpdate(Weather_Temp_Min, Weather_Temperature.minimumSince(startOfDay, "influxdb").state)

It is saving values just fine and Grafana is charting them just fine. These are the only calls I have to pull historic data from InfluxDB.

The “DEFAULT” all upper case is coming presumably from the addon. It isn’t in any of my configs or the Rule.

I haven’t used such calls, however I do believe that the error you see is caused by an incomplete change from “default” to “autogen”.
My personell solution was to use a named persistence, however I did only check with the REST API from OpenHAB. I can’t say if the calls you are using will be handled with the name of the persistence.
Since @theo made this change to the binding, he should be able to tell. Or could I have a look into the code, but how?

I am using the named persistence in the calls above. My default is mapdb so I must supply “influxdb” to get at the data from there.

When I try to use autogen nothing works and the logs are full of errors. Prior to this most recent update these calls worked just fine.

Sorry wrong word, not named persistence, we were talking about InfluxDB persistence, what I tried to say wax named retention policy. I’m sorry.

Had a look into the code ( InfluxDBPersistenceService.java / at least I think that is the correct one).
As far as I understand the retention-policy is added to each query. Could you try it with the logger set to debug for this bundle? THAT way the query -string should be logged ( I think ).

How to solve my problem?

That is to my knowledge not possible. The identifier is the unique identifier for this Item and should therefore be used for these kinds of relations. The label you choose for an Item is not unique and hence not a good candidate.

I believe there is a better way to solve your problem. If you are concerned about the “83020000…” not being intuitive, you should just rename the item!? If you want to make Grafana graphs show nicer labels, use the alias function there.

Aliases have to maintain relevance in Grfanane and openhab, but would like to have one system where the sensors are configured and their names

I have to agree that would be nice.
@theo, @opus: to your knowledge of InfluxDB and the current state of the bidning, could the item label be stored besides the measurements? tag_hostname seems currently not set, maybe a tag tag_label/tag_alias would be nice. http://docs.grafana.org/datasources/influxdb/#alias-patterns

2016-11-15 11:05:00.003 [DEBUG] [.internal.InfluxDBPersistenceService] - got a query
2016-11-15 11:05:00.003 [TRACE] [.internal.InfluxDBPersistenceService] - Filter: itemname: Weather_Temperature, ordering: ASCENDING, state: null,  operator: EQ, getBeginDate: Tue Nov 15 00:00:00 MST 2016, getEndDate: null, getPageSize: 2147483647, getPageNumber: 0
2016-11-15 11:05:00.003 [TRACE] [.internal.InfluxDBPersistenceService] - appending limit 2147483647
2016-11-15 11:05:00.004 [TRACE] [.internal.InfluxDBPersistenceService] - startEntryNum 0
2016-11-15 11:05:00.004 [DEBUG] [.internal.InfluxDBPersistenceService] - query string: select value from default.Weather_Temperature where  time > 1479193200s  limit 2147483647
2016-11-15 11:05:00.008 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule Update max and min temperatures: {"error":"error parsing query: found DEFAULT, expected identifier at line 1, char 19"}

The log lines immediately above that are it successfully saving values

As far as I can tell, that query looks OK. However the “default” written in bold makes me wonder. I guess that this problem is above my knowledge. Maybe @theo can help.

Did some testing using my setup (InfluxDB with a user-named retention policy).
I used this rule:

rule “NewTest”
when
Item TestSomething changed
then
val StartOfDay =now.withTimeAtStartOfDay
val StoredValue =MyItem.minimumSince(StartOfDay,“influxdb”)
logInfo(“NewTest”,“StoredValue= {}”, StoredValue.state)
end

I’m not getting and error, only this this log-entry:

18:01:46.908 [INFO ] [lipse.smarthome.model.script.NewTest] - StoredValue= 1.209

I didn’t check the debug-output of the influxdb-binding (because I don’t know the exact name of the package :blush:)

I couldn’t get it to log right either. I just put all of OH into trace mode and grepped the logs.

When I have some time I might try making a new retention policy, though I hate to lose all that historical data.

I would also hate to lose my data. @ThomDietrich posted in reply #84 in this thread a method to copy data from one database or retention policy to another.

1 Like

I should move that information to the first article…

@rlkoshak could you please execute this query using the influx client:
select value from default.Weather_Temperature where time > 1479193200s limit 2147483647