RRD4j - REST/persistence

Hi.

I’am trying to get data from the rrd4j with the rest api service.

But when I add a starttime and endtime the second value I get is always lower then the first.
I’am I doing something wrong?

IP:PORT/rest/persistence/elmeter?servicename=rrd4j&starttime=2016-07-22T00%3A00%3A01&endtime=2016-07-24T23%3A59%3A59

This is the response:
{
“name”: “elmeter”,
“datapoints”: “311”,
“data”: [
{
“time”: 1469138401000,
“state”: “6045.5”
},
{
“time”: 1469138160000,
“state”: “6045.5”
},
{
“time”: 1469139000000,
“state”: “6045.5”
},
{
“time”: 1469139840000,
“state”: “6045.5”
},
{
“time”: 1469140680000,
“state”: “6045.5”
},
{
“time”: 1469141520000,
“state”: “6045.5”
},

converted:

I’ve not tried this with RRD. The persistence request does two requests - firstly to get the last value before the start time, then another request to get the actual data. Maybe RRD doesn’t support the reverse filter…

I’m currently updating the persistence rest service so I’ll take a look over the next day or two.

I think there’s something wrong with your time conversion!

1469138401000 is Thu, 21 Jul 2016 22:00:01 GMT, not 07-22-16 00:00:01 as you calculated.

Currently, the first time in the response is always the time of the request (and we see this here once the correct conversion is applied). Then I suspect that what is happening is that due to the RRD sampling it returns data ‘around the time you request’ - it’s not necessarily after, and in this case it’s about 4 minutes earlier.

I guess this is a ‘feature’ of RRD - it doesn’t return the data that was recorded and is one of the reasons I personally don’t like it. Maybe we can solve some of this in the persistence API, but to RRD will never return the same data you put into it due to the way it works…

I hope this helps.

Hi.

About the conversion I ad +02:00 in the conversion to match our timezone.
And as you can see, the start time is 2016-07-22T00:00:01.

I just thought the RRD is really simple because I dont need an external database.

But I am willing to try something else.
Which databases works well with the Persistence API??

I would suggest using H2. This is also just as simple - it’s a fast embedded database so nothing else to install or configure and it records data ‘properly’.

Imho rrd4j does a very good job and it is the only database that does not grow over time, so you do not have to continuously maintain it.
That the result is not chronologically is imho not the fault of the database itself, I very much assume that this is a bug of the persistence service implementation that would need to be fixed.

Yes, I think it’s an issue in the RRD persistence service. When we ask for a certain time (ie set in the filter) it looks like RRD is returning data that is outside this time window. I’ve not looked at this in detail as I don’t use RRD so if someone with more knowledge of how the RRD persistence service is implemented wants to take a look, it would be good.

@carzten2000 Could you enter a bug report for it at https://github.com/openhab/openhab/issues?