go-graphite / carbonapi

Implementation of graphite API (graphite-web) in golang
Other
309 stars 140 forks source link

hitcount() produces incorrect results when the interval parameter is smaller than the fetched data's step #760

Closed carrieedwards closed 1 year ago

carrieedwards commented 1 year ago

Describe the bug If the interval parameter passed into the hitcount() function is smaller than the step of the data, the results are incorrect. The results will be shifted left, and buckets to the right will be empty.

For example:

hitcount(metric1, "6m") []*types.MetricData{{"metric1", 0, 1}: {types.MakeMetricData("metric1", []float64{2, 4, 6}, 600, 100)},} // 10m step

The result will be []float64{1200, 2400, 3600, 0, 0, 0}. The hit values are all concentrated on the left half of the buckets.

When the same test is run in Graphite web, the results are [720, 960, 1440, 1920, 2160], with the hit values spread throughout all of the buckets.