1

I have a RRD created by this command

===

data_sources = [ 'DS:Pprod:GAUGE:10:0:6000',     
             'DS:Pcons:GAUGE:10:0:6000', 
             'DS:Pdiff:GAUGE:10:-6000:6000'  
           ]

rrdtool.create ( rrd_filename,
                 '--step', '5',                      # one sample every 5 sec
                 '--start', 'now - 7d',
                 data_sources,
                 'RRA:MAX:0.5:1:6307200')            # we keep 1 year

===

I am filling it properly -

===

    <!-- 2022-05-19 12:25:45 CEST / 1652955945 --> <row><v>4.291018731e+03</v><v>1.715717220e+03</v><v>2.574301511e+03</v></row>
    <!-- 2022-05-19 12:25:50 CEST / 1652955950 --> <row><v>4.286880929e+03</v><v>1.721000000e+03</v><v>2.564880929e+03</v></row>
    <!-- 2022-05-19 12:25:55 CEST / 1652955955 --> <row><v>4.286880929e+03</v><v>1.721000000e+03</v><v>2.564880929e+03</v></row>

===

Now I want to "xport" some data from it :

rrdtool xport -s $epochStart  -e $epochEnd  --step 5 --json  -t   DEF:pot=$ifn:Pprod:MAX XPORT:pot 

===

And in the output JSON I find the "step" has changed :

{ "about": "RRDtool graph JSON output",
  "meta": {
    "start": 1652738755,
    "end": 1652824970,
    "step": 215,
    "legend": [
      ""
          ]
     },
  "data": [
    [ "1652738755",0.000000000e+00 ],
    [ "1652738970",0.000000000e+00 ],

===

Any logical reason for that ?

PD.- "rrdtool info" says

pi@R4:~/python/pkw/dades $ rrdtool info ./pkw.rrd 
filename = "./pkw.rrd"
rrd_version = "0003"
step = 5
Steve Shipway
  • 3,754
  • 3
  • 22
  • 39
Mikel Vergy
  • 121
  • 5

1 Answers1

0

This is most likely caused by trying to export data outside of the current rage for the defined RRA.

Your RRD has only a single RRA defined, from (now-7d) until (6307200x5sec) in the future.

The data you show as being added to the RRD are for times around epoch=1652955945; but the export you are trying is for times around epoch=1652738755, before the RRA starts.

When I tried to duplicate this, I created an RRD:

rrdtool create $RRD --step 5 --start 1652955935 \
  'DS:Pprod:GAUGE:10:0:6000' 'DS:Pcons:GAUGE:10:0:6000' \
  'DS:Pdiff:GAUGE:10:-6000:6000' 'RRA:MAX:0.5:1:6307200'

Then added data to it

rrdtool update $RRD \
  1652955940:0:10:20 \
  1652955945:100:200:300 \
  1652955950:400:500:600 \
  1652955955:700:800:900 \
  1652955960:1000:1100:1200

If I try to extract the data from within the range of the defined RRA, then it works:

rrdtool xport -s 1652955945 -e 1652956000 --step 5 --json \
  -t DEF:pot=${RRD}:Pprod:MAX XPORT:pot

{ "about": "RRDtool graph JSON output",
  "meta": {
    "start": 1652955950,
    "end": 1652956000,
    "step": 5,
    ...

However, if I try to extract from a range that is not within the available data space, RRDTool fails to pick a meaningful RRA and so appears to default to a 215s step.

rrdtool xport -s 1652738755 -e 1652824970 --step 5 --json \
   -t DEF:pot=${RRD}:Pprod:MAX XPORT:pot

{ "about": "RRDtool graph JSON output",
  "meta": {
    "start": 1652738970,
    "end": 1652824970,
    "step": 215,
    ...

I don't know why RRDTool is defaulting to this step size; however, it is documented behaviour that RRDTool, when doing a graph or xport, will attempt to find the best-fit RRA to cover the entire requested data range at the requested consolodation, even if this means changing the step size. So, this looks as if RRDTool has given up on finding a workable RRA and has given you a default of 215s step with empty data.

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