Graphing a COUNTER value with RRD4J

I am trying to set up persistence and graphing for counter values (e.g. water and power meter readings translated into use per unit time). The RRD type COUNTER is usually used for this and stores the delta between readings (e.g. 3 gallons) as opposed to the absolute reading itself (e.g. 287,145 gallons).

I have tried to set this up using the relatively new custom RRD4J configs, but something is not working right. I always get a blank graph:

Here are the relevant config snippets:

openhab.cfg

rrd4j:util_meter.def=COUNTER,3600,0,100000000,60
rrd4j:util_meter.archives=AVERAGE,0.5,1,480
rrd4j:util_meter.archives=AVERAGE,0.5,4,360
rrd4j:util_meter.archives=AVERAGE,0.5,15,644
rrd4j:util_meter.archives=AVERAGE,0.5,60,720
rrd4j:util_meter.archives=AVERAGE,0.5,720,730
rrd4j:util_meter.archives=AVERAGE,0.5,10080,520
rrd4j:util_meter.items=Water_Meter_Total

main.items

Number Water_Meter_Total "Total gallons used [%d]" (Test,Water,Sensors) {modbus="watermeter:0"}

rrd4j.persist

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
	// for rrd charts, we need a cron strategy
	everyMinute : "0 * * * * ?"
}

Items {
    Sensors* : strategy = everyMinute, restoreOnStartup
    Temperatures* : strategy = everyMinute, restoreOnStartup
    Power* : strategy = everyMinute, restoreOnStartup
    Water_Meter_Total : strategy = everyMinute, restoreOnStartup
    Lights* : strategy = everyChange, everyMinute, restoreOnStartup
}

No errors or anything interesting I could find in the logs. The value for Water_Meter_Total displays in the UI properly and gets updated when I use water.

Any ideas?

Hi. Did you manage to get this to work? I’m using v1.8.0 with a similar configuration and all I see is an empty chart with not even the legend (like you). I also tried to configure the series as a GAUGE to replicate what OH does and I get the same empty graph. I can tell the my data source is capturing the right items because if I remove it from the.cfg file then I get the regular OH graphs.

Any clues?

Thanks

Unfortunately, I was never able to get this to work. :confused:

I’ll raise this topic again…
Same situation as described by @andy_swing.
Graphing in the sitemap works only if I’m using the the predefined/implicit defnames default_numeric or default_other, But: This is only suitable for ds-type GAUGE. When ds type COUNTER is required, the openhab.cfg and the wiki at

suggests configuring a own defname for it, like:

Declared the rrd defnames like:
rrd4j:regen.def=COUNTER,3600,0,U,300
rrd4j:regen.archives=TOTAL,0.75,1,864
rrd4j:regen.archives=TOTAL,0.75,3,864
rrd4j:regen.archives=TOTAL,0.75,12,864
rrd4j:regen.archives=TOTAL,0.75,2016,530
rrd4j:regen.items=WS1200Rain,RegenMenge

But if doing so, the resulting rrd is not used by the graph widget. The graph remains empty.

When removing the specific defname from openhab.cfg, the graphing works for the default rrd persistence behaviour (GAUGE), like @mcuenca said already. Therefore, persisting the values is working.

It seems to me, the sitemap graphing is limited to the default defnames. Bug?
Should I raise a issue at the bug tracker?

Edit:
When looking into debug log, it seems, persistance is storing every value twice, but for COUNTER rrds it stores STEP*Value the first time and than immediately the actual value again:

09:33:00.008 [DEBUG] [.p.rrd4j.internal.RRD4jService:111 ] - Stored ‘WS1200Rain’ with state ‘1782.000000000000227373675443232059478759765625’ in rrd4j database (again)
09:33:00.009 [DEBUG] [.p.rrd4j.internal.RRD4jService:130 ] - Stored ‘WS1200Rain’ with state ‘29.7000000000000028421709430404007434844970703125’ in rrd4j database
09:33:00.256 [TRACE] [o.c.p.internal.PersistItemsJob:56 ] - Storing item ‘WS1200Rain’ with persistence service ‘rrd4j’ took 250ms
09:33:00.259 [DEBUG] [.p.rrd4j.internal.RRD4jService:111 ] - Stored ‘WS1200Temp’ with state ‘10.9000000000000003552713678800500929355621337890625’ in rrd4j database (again)
09:33:00.261 [DEBUG] [.p.rrd4j.internal.RRD4jService:130 ] - Stored ‘WS1200Temp’ with state ‘10.9000000000000003552713678800500929355621337890625’ in rrd4j database
09:33:00.300 [TRACE] [o.c.p.internal.PersistItemsJob:56 ] - Storing item ‘WS1200Temp’ with persistence service ‘rrd4j’ took 43ms
09:33:00.303 [TRACE] [o.c.p.internal.PersistItemsJob:56 ] - Storing item ‘AussenTemp’ with persistence service ‘rrd4j’ took 2ms
09:33:00.306 [DEBUG] [.p.rrd4j.internal.RRD4jService:111 ] - Stored ‘RegenMenge’ with state ‘2826’ in rrd4j database (again)
09:33:00.308 [DEBUG] [.p.rrd4j.internal.RRD4jService:130 ] - Stored ‘RegenMenge’ with state ‘47.10000000000000142108547152020037174224853515625’ in rrd4j database

The first value is exactly 60 times the actual counter value (which is the rrd step size). When defining 300 seconds step size, the first store is 300 times of the actual counter. Is this expected behavior? Currently don’t understand it :frowning:

It is an old topic, but I’ve just been struggling with the same.
I am replying, since it may help others.
The issue with configuration above is that there is a separate line for each archive, while they should be in one line separated by semicolons.
With multiple lines, only last rule is applied, which means your data would be updated after a year or so.
This is specifically misleading, because old way of specifying the rules by calling addArchive() works in separate lines. But it does not work in case of rrtd4j.cfg file.
Cheers
Pawel

1 Like