Change rrd4j policy for 2 databases

Do have a running setup with a few databases. I am fine with persistence strategy for most databases. But for 2 of them I want to have something else. I need better time resolution for the first 12h (instead of just 1 hour). I read about

but I don’t get it really. The problem: For the default there are no files at all, so nothing easily to modify.

As far as I understand I don’t need a rrd4j.persist file, but one services/rrd4j.cfg. But where to store that? The location for rrd4j.persist is described, but not for that services folder…
So can you help me what is needed to extend the 10s resolution to 12h for a database named:
/persistence/rrd4j/sm_consumption.rrd ?

Can this modification be done in Web-IF or in console?

What happens with already existing data? Probably a new file will be created and old stuff is not valid anymore?

According to the docs the default resolutions are:

It defines 5 archives:

granularity of 10s for the last hour
granularity of 1m for the last week
granularity of 15m for the last year
granularity of 1h for the last 5 years
granularity of 1d for the last 10 years

So IIUC you want to introduce a new datasource for 12h with a granularity of 10s.

No but there are many examples in the docs you linked to as well as an explanation of each of the fields and the math you’ll need to do to figure out the proper values to enter for each field. But having an example is going to have limited value for you because rrd4j is pretty arcane and all the properties interact with each other. You kind of have to be knowledgable in rrd4j internals to use the examples anyway.

But the defaults are in the docs:

default_numeric.def=GAUGE,600,U,U,10
default_numeric.archives=LAST,0.5,1,360:LAST,0.5,6,10080:LAST,0.5,90,36500:LAST,0.5,360,43800:LAST,0.5,8640,3650

That doesn’t use the last line because it applies to all Items that are not otherwise listed elsewhere in an rrd4j.cfg file.

Doesn’t really help much to have the example, does it.

Under the services folder in $OH_CONF. Where is $OH_CONF? Depends on how you installed OH. There is a table in the installation instructions explaining where each important folder is. For Linux see openHAB on Linux | openHAB. You already know where to put this because the .persist file is $OH_CONF/persistence/rrd4j.persist.

No

It will almost certainly become corrupted for that Item (note that custom datasource definitions get applied to individual Items, not across all of your Items).

I’ve never tried to move from the default datasources in rrd4j. But based on the docs I’d expect it to look something like the following:

my12h.def=GAUGE,600,U,U,10
my12h.archives=LAST,0.5,1,4320:LAST,0.5,6,10080:LAST,0.5,90,36500:LAST,0.5,360,43800:LAST,0.5,8640,3650
my12h.items=Item1,Item2

The above datasource has two changes from the default (see above).

The first archive has been expanded to 12 hours by increasing the ` field (archive time = sampleInterval * samplePerBox * boxCount). Multiplying the box count by 12 increases the first archive to cover the first 12 hours instead of the first hour. You could multiply any of the fields by 12 and get the same result, but I’m not sure what the implications are to changing the sampleInterval or samplePerBox on the down stream compression.

The second change is the addition of the my12h.items line. You have to list the names of the Items individually that will use this datasource instead of the default. Put those three lines in under $OH_CONF/services/rrd4j.cfg.

Thank you - think I almost understand. But I am confused about what <dsName> is and whats than a <dsName>.item ?
My item is sm_consumption

/etc/openhab/services/rrd4j.cfg :
sm_consumption.def=GAUGE,10,0,U,10
sm_consumption.archives=AVERAGE,0.5,1,4320:AVERAGE,0.5,6,10080
according to my undertstanding this saves an value every 10s (4320x) = 43200s=12h, and for a week every 1min (6*10s)*10080.
Right?

Mhh, reading a third time this dsName seems free to chose but I have to add
sm_consumption.items=sm_consumption

It’s what ever you want it to be. It’s what tells rrd4j that these three lines of config go together. It’s just a unique identifier. That’s why I used “foo12h” above. It just doesn’t matter so long as the three config lines match.

From the docs:

List of Items whose values shall be sampled and stored in the archive. The format is Item1,Item2 Note: the same Item is not allowed to be listed in more than one datasource!

I don’t know how to reword it to be more clear. You need to list the Items that are to use this datasource on that line. Above I just used “Item1,Item2” because I don’t know how many Items you want to change and what they are called.

Use code fences.

```
code goes here
```

I think so. As documented

The time span covered by a full archive is therefore (<sampleInterval> x <samplesPerBox> x <boxCount> ) seconds.

so you have 10 * 1 * 4320 = 43200.

I’ll sate it again, I don’t know the implecations of changing the samplePerBox so there might be side effects to changing that.

But what about the rest of the archives? You don’t inherit the defaults as I understand it. You need to provide archives for year, 5 years and 10 years or I expect your files will be huge.

1 Like

My understanding was that (if this both archives - every 10s and every min) is full, so after 1 week, old data will be overwritten. That is ok for this example, but I might change that, true.