Reputation: 728
I have a counter metric, which I will call a.metric.count
When graphed normally this would be an ever-increasing upwards line, which is not that useful. What I would like is to show the number of events which occurred every hour.
Upvotes: 3
Views: 3278
Reputation: 61
Also using diffSeries, but results in a little bit of a nicer graph:
diffSeries(
sumSeries(a.metric.count),
sumSeries(timeShift(a.metric.count, "1h"))
)
If you want to avoid the ending spike you can use a double offset:
diffSeries(
sumSeries(timeShift(a.metric.count, "1h")),
sumSeries(timeShift(a.metric.count, "2h"))
)
Keep in mind that with this method you will be behind by the smaller offset.
Upvotes: 2
Reputation: 2272
Use the derivative
function, as documented here: http://graphite.readthedocs.org/en/1.0/functions.html#graphite.render.functions.derivative
That will, at each data point, show how much the value increased from the previous timeseries datapoint.
If you want to view it on a per-hour basis, you can use summarize
, as documented here: http://graphite.readthedocs.org/en/1.0/functions.html#graphite.render.functions.summarize
So, to view the hourly increase in .count, you could do:
summarize(derivative(a.metric.count), "1hour")
Upvotes: 8
Reputation: 728
First of all we need two different graphs:
a.metric.count
timeShift(a.metric.count, "1h")
Next we need to summarise these by hour, using the last value recorded for each hour:
summarize(a.metric.count, "1h", "last")
summarize(timeShift(a.metric.count, "1h"), "1h", "last")
Now we just need to show the difference between the two graphs:
diffSeries(summarize(timeShift(a.metric.count, "1h"), "1h", "last"), summarize(a.metric.count, "1h", "last"))
The only trouble with this approach is that the data for the latest hour is wrong because there is no "last" value on the non-timeshifted graph, which means that the graph will spike
Upvotes: 0