New 'derives' functionality added #337

wants to merge 1 commit into


None yet

3 participants


This update adds a derives type to statds to allow the creation of counters based on N/second but given counts that are always increasing.

mrtazz commented Sep 5, 2013

Thanks for the pull request! Can you give some more insight into the purpose of derives and what use cases you have for them? Would love to hear more about it.


Derives are used when you're logging/graphing counters. Think of derives as the 'per second' counter.

for example: # of bytes sent (on an interface). The number is always going up, but you're really interested in determining (and graphing) the rate of bytes / second. So if you're querying an interface and it provides an always increasing counter like this:
input (10 sec interval): 1000 kbytes, 1500 kbytes, 2200 kbytes, 3000 kbytes, 3200 kbytes
output from derives: 50 kbytes, 70 kbytes, 80 kbytes, 20 kbytes, or the slope of the change in values over time (di/dt).

They're named 'derives' because that's what they're named in RRD, but if someone has a better name I'm open to it.

the formula for the 'value' of a derive counter is:
VALUE = (thisval - lastval) / (now - lasttime);
but only when thisval > lastval (which deals with counter resets/wraps)

mrtazz commented Apr 14, 2014

Hmm ok, this is interesting. It sounds like something where sending a gauge and let the graphing backend handle the derivation would be preferable. I basically gives you the same functionality with more flexibility and less state handling. I would guess having a derive() function is pretty standard by now or am I wrong with this?

sbrynen commented Apr 29, 2014

While graphite supports a derive natively, sometimes it's handier and a lot cleaner if all of your data in your graphite archive in the same style, ie all gauges in the form of N/second. Frankly it's a pain if you have to know that your router needs a derive but your web server output is already derived into N bytes/seconds. Especially difficult when you're trying to explain it to helpdesk/product management staff who end up creating useless graphs because they don't understand why the data is in different formats.

Statsd already does
integration (sums of events over a period)
guages (raw),
adding derive (slope) to statsd completes the set of transforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment