Search code examples
rrdtoolrrd

Write data to an RRD at irregular intervals


I'm trying to find out if I can store values captured at irregular intervals into an RRD.

I have a script which connects to an ActiveMQ server subscribes to a queue or topic and looks at the message header time stamp, compares it with Time.now to give me a delta.

The data I get from my script is as below;

000000.681 Time Delta
000000.793 Time Delta
000000.583 Time Delta
000001.994 Time Delta

The issue I face is that messages from the ActiveMQ don't necessarily come in at a 'regular interval' (e.g 1/sec, 1/2sec) They could come in at peak times as 5 a second, and quite times 1 every 10 seconds.

I'd like to be able to capture the output into an RRD so I can graph against it but having a look around on the internet it's not clear is this can be done, or if I'd be better off using a.n.other database/store to capture the data into.

The eventual output I'd like would be a graph showing the time delta for each message.

It looks like I could set the RRD using --step to 1 second, and the hart beat to 2 seconds having had a read of the docs.

I found a couple of posts here and here which talk about being careful with the intervals and the fact my data might be averaged, smoothed or otherwise messed about with when written to the RRD. But nothing I've found online has a similar usage case to mine so its a bit hard to know where I should be looking. I'd like my data to be stored as point for each message received.

I have a couple of RRD's setup for testing; one is taking the AVERAGE the other is taking the LAST to produce some graphs. My heartbeat is set for 100 seconds, but the interval is set to 1. I'm now getting data which looks correct. I'm also guessing that empty spaces in graph from the LAST RRA are due to my data coming in slower that 1 per second?

I'll post my create code & output as an answer.


Solution

  • rrdtool will always store data at regular intervals. As data is handed over to rrdtool, it first gets re-sampled to the --step interval. and then further consolidated to the intervals setup in the RRAs.

    The exact arrival time of the data (to the millisecond) is taken into account as the re-sampling takes place ...

    If two data points are further apart than specified by mrhb, the data is considered non-continuous and rrdtool will store 'unknown' for the interval affected.