2013-05-27 13:59:50 by jdixon
There's been many a time when I've asked the question "I wonder how many hosts are sending this metric?" Unfortunately there's no built-in Graphite function for determining the number of hosts submitting a particular metric (or tree of metrics). But this morning I stumbled across a brilliant hack of a Graphite query by Jesse Newland (@jnewland) for rendering this value.
Jesse realized that we could count them simply by converting each value to 1 and then adding them up. We make this happen by first applying scale(0) to the series and then incrementing each by one with offset(1). Lastly we use sumSeries() to render our final tally.
/render/?target= alias( sumSeries( offset( scale( collectd.*.load.load.longterm, 0), 1) ), "hosts")
And here is the resulting graph: