Yuriy Zubarev
Yuriy Zubarev

Reputation: 2871

Split continuous counter by time period

I have a series list *.in.count that represents number of messages going into a queue. If I plot the list as-is it will be a perpetually going up line:

enter image description here

What I want to know is how many messages go into a queue aggregated and summed by hour, and reset by day. Something like this:

enter image description here

I experimented with Graphite functions but couldn't find a way to achieve this.

Upvotes: 1

Views: 2771

Answers (2)

Sasha
Sasha

Reputation: 1411

Old question but for the sake of other searchers:

To sum up or calculate count(total) per interval:

hitcount(perSecond(your.count), '1day')

Afaik it does all the black magic inside. Including but not limited to summarize(scaleToSeconds(nonNegativeDerivative(your.count),1), '1day') and also there should be scaling according to carbon's retention periods (one or many) that fall into chosen aggregation interval.

Upvotes: 0

Matt Self
Matt Self

Reputation: 20095

To aggregate events over time in Graphite you can combine the usage of group(), sumSeries(), and summarize(). The group function pulls metrics into a single series, then sumSeries adds them up, then summarize aggregates them for an interval.

For example:

1 hour sums:

summarize(sumSeries(group(*.in.count)),"1h")

or

1 day sums

summarize(sumSeries(group(*.in.count)),"1d")

Then, to get the graph to look like you want (i.e. like a bar chart), you should set the "Line Mode" to Staircase Line and "Area Mode" to Stacked or All.

Upvotes: 4

Related Questions