0

First. I created a rrd database

$ rrdtool create test.rrd --start 1200000000 --step 300 DS:test_1:GAUGE:600:0:100 RRA:AVERAGE:0.5:1:12

Second. do some updates

$ rrdtool update test.rrd 1200000100:1
$ rrdtool update test.rrd 1200000400:3
$ rrdtool update test.rrd 1200000700:4
$ rrdtool update test.rrd 1200001000:5

Third. fetch data from test.rrd

$ rrdtool fetch test.rrd -r 300 -s 1200000000 -e 1200001000 AVERAGE

Why 1200000300 is 2.333?

2 Answers2

2

This is caused by Data Normalisation. RRDTool will automatically adjust data to fit exactly on the time boundary of the defined Interval.

Although your data are spaced exactly at 300s intervals, the same as your defined Interval (step), unfortunately they are not on the actual boundaries.

The boundary is when time modulo step is equal to zero. In your case, that would be at time 1200000000 and not at 1200000100. Thus, the sample needs to be adjusted (one third of it allocated to the earlier interval, and two thirds to the later). This is further complicated because you are operating in Gauge mode whereas RRDTool works interpolates assuming a linear rate of change of the rate.

If you started your samples at time 1200000300 or at 1200000000 then you would see them stored exactly as given, because the normalisation step would become a null operation. Since you provide a Gauge sample at 1200000100 and 1200000400 , the stored value for 1200000300 will be two-thirds along a line joining the two sample: 1 + ( 3 - 1 ) x 0.666 = 2.333 which is what you are getting.

The tutorial by Alex van den Bogeardt here will explain it all to you.

Steve Shipway
  • 3,754
  • 3
  • 22
  • 39
0

The root cause of it is the calculation of PDP (primary data point), you can refer to this answer which provided a perceptual explanation and exemplar calculation process.

Xavier Z.
  • 128
  • 10
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34503308) – user12256545 Jun 11 '23 at 11:46