graphitestatsdgraphite-carbon

why do i get N+1 datapoints from graphite, when i just asked for N datapoints?


  1. render?target=summarize(\*.\*.\*.count,'15min','sum')&from=12:07_20131110&format=json&until=12:22_20131110
    

    I expect 1 data point here but i get 2

    [{"target"=>"summarize(foo.example.abc.count, \"15min\", \"sum\")", "datapoints"=>[[nil, 1384113600], [3.0, 1384114500]]}] 
    
  2. render?target=summarize(\*.\*.\*.count,'1hour','sum')&from=12:24_20131109&format=json&until=12:24_20131110
    

    I expect 24 data points here but i get 25, for last 24 hours

    [{"target"=>"summarize(foo.example.abc.count, \"1hour\", \"sum\")", "datapoints"=>[[nil, 1384027200], [nil, 1384030800], [nil, 1384034400], [nil, 1384038000], [nil, 1384041600], [nil, 1384045200], [nil, 1384048800], [nil, 1384052400], [nil, 1384056000], [nil, 1384059600], [nil, 1384063200], [nil, 1384066800], [nil, 1384070400], [nil, 1384074000], [nil, 1384077600], [nil, 1384081200], [nil, 1384084800], [nil, 1384088400], [nil, 1384092000], [nil, 1384095600], [nil, 1384099200], [nil, 1384102800], [nil, 1384106400], [4.0, 1384110000], [4.0, 1384113600]]}]
    

Here until always points to current time. Please can anybody explain why it is so? and how to restrict data points to be according to my expectation?


Solution

  • I've changed my mind from what I said in the comments.

    I looked at the Graphite documentation for summarize().

    The issue is that, by default, the buckets align to the interval. If you specify an interval of '15min', from=12:07_20131110, and until=12:22_20131110, then there will be two buckets. The first will be 12:00-12:15 and the second will be 12:15-12:30. Likewise, if you specify an interval of '1hour', from=12:24_20131109, and until=12:24_20131110, then there will be 25 buckets. The first will be 12:00-1:00 on 2013-11-09 and the last will be 12:00-1:00 on 2013-11-10.

    The problem, such as it is, is that the buckets are aligned to the interval but your from and until times are not. You can specify alignToFrom=True to specify buckets that align to your from time. I'm not certain that that will give you the number of buckets you want, but it should make it more obvious which bucket you should discard because, if there's an "extra" bucket, it will fall almost entirely outside of your from-until range.