Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

graphite summarize datapoints

Tags:

I'm using graphite to collect data, and I'd like to retrieve the total count of certain events over a period of time. Say, number of logins per week.

However, I just need the total number, and don't need to see how it evolves over time.

When I use something like from=-1w&target=summarize(stats.events.login.success,"1w")&format=json then I still get two datapoints, and not one.

Is there a way to get a single datapoint from the summarize function? or use a different function to return a single datapoint value?

like image 574
gingerlime Avatar asked Nov 27 '12 17:11

gingerlime


1 Answers

The problem here is that summarize doesn't align to the from field by default.

summarize(seriesList, intervalString, func='sum', alignToFrom=False)

If you do

from=-1w&target=summarize(stats.events.login.success,"1w","sum",true)&format=json

you should get just one datapoint. What it's doing right now is aligning your buckets to dates that don't fit within the week range starting from your from parameter, so you end up with 2 buckets. From the graphite docs on summarize:

By default, buckets are caculated by rounding to the nearest interval. This works well for intervals smaller than a day. For example, 22:32 will end up in the bucket 22:00-23:00 when the interval=1hour.

Passing alignToFrom=true will instead create buckets starting at the from time. In this case, the bucket for 22:32 depends on the from time. If from=6:30 then the 1hour bucket for 22:32 is 22:30-23:30.

like image 183
mmrobins Avatar answered Sep 19 '22 03:09

mmrobins