0
  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?

Machavity
  • 30,841
  • 27
  • 92
  • 100
Sachin Singh
  • 7,107
  • 6
  • 40
  • 80
  • 1
    [Fencepost error](https://en.wikipedia.org/wiki/Off-by-one_error#Fencepost_error) – Ken Thomases Nov 11 '13 at 06:13
  • @KenThomases, please can you explain how to fix it? – Sachin Singh Nov 11 '13 at 07:14
  • You need to think clearly about what you expect to get. You say *how many* data points you expected but not *which*. Do you want the starting time to be included? Do you want the ending time to be included? You probably just want to ignore either the first or the last element of the returned array, but there's no way for me to know. It depends on what you're trying to achieve. – Ken Thomases Nov 11 '13 at 07:51
  • @KenThomases, i need the last data-point, thanks please add your comments as answer to this question so that i can accept it. – Sachin Singh Nov 11 '13 at 10:31

2 Answers2

1

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.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
0

Perhaps this behavior is so because, two n+1 limiting ends are required to frame n intervals.

Pass on the exact UNIX time epochs to from and until.

erbdex
  • 1,899
  • 3
  • 22
  • 40
  • `render?target=summarize(*.*.*.count,'15min','sum')&format=json&from=1384077500&until=1384077600` – erbdex Nov 11 '13 at 07:27
  • these type of parameters are not supported in graphite doc http://graphite.readthedocs.org/en/latest/render_api.html?highlight=until – Sachin Singh Nov 11 '13 at 07:30