How do you graph switch interface counters that rollover?

Asked by dw-davef

I realized you can take the derivative of a counter to get its rate of change, the issue I have is the counter rolls over quite often, sometimes within a polling period, so my derivative graph contains a -100000000 data point when the counter flips.

Is there a switch counter setting like rrd has that can handle the rollover?

Question information

Language:
English Edit question
Status:
Answered
For:
Graphite Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
chrismd (chrismd) said :
#1

There is another function, nonNegativeDerivative() to handle situations exactly like this, it will treat any decreases in value as 0. This is available in the latest trunk.

Revision history for this message
dw-davef (davef-demonware) said :
#2

I think there is a bug in the non negative derivative function, because instead of the data point being treated as zero, the derived graph plots a data point at zero. So if I have a network interface that has a constant rate of 100 mbit/sec, the graph drops to zero every time the counter rolls over, which screws over the scaling of the graph. It would be more useful to ignore or interpolate any decreases.

Revision history for this message
chrismd (chrismd) said :
#3

Yes this is actually a tricky problem. So nonNegativeDerivative just calculates the differences between each two successive data points and displays that, unless the difference is negative in which case it displays zero. The reason this is tricky is because the only way for graphite to display the "correct" value is to know what the maximum value is (ie. where the counter wraps). Since graphite doesn't know that we have to basically just make up a value and initially I chose zero as a default. My counters tend to wrap infrequently and I liked seeing the zero as an indication that they had. In your case it sounds like it would be better to just retain the previous value. I don't really like either solution because both are inaccurately representing the real data.

So I think I've come up with a good solution that can more accurately represent the data. What I'll do is change the default behavior to be that whenever the difference between two successive data points is negative I'll have it yield a null value (a gap in the data). This is technically more "honest" since graphite doesn't know what the value is. What you can do then is simply wrap these calls with the keepLastValue() function which replaces all null values with the closest non-null value that precedes them.

In addition I'll add the ability to specify an extra parameter to nonNegativeDerivative that specifies the maximum value explicitly. Using this should make the graph always be accurate. Technically it is possible for the counter to wrap more than once within an interval but there's no way for graphite to handle that case so I'll just ignore it :)

Can you help with this problem?

Provide an answer of your own, or ask dw-davef for more information if necessary.

To post a message you must log in.