go-graphite / carbonapi

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

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

Closed carrieedwards closed 1 year ago

carrieedwards commented 1 year ago

If the interval parameter passed into the smartSummarize() function is smaller than the step of the data, the results are incorrect.

For example:

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

The result will be []float64{2, 4, 6}.

When the same test is run in Graphite web, the results are [2, 4, None, 6, None]. This is due to the interval being smaller than the step, and therefore some resulting values will be NaN.

Additionally, smartSummarize does not support all of the possible alignTo values. Currently, only minutes, hours and days are supported, while Graphite web supports seconds, minutes, hours, days, weeks, months and years.

See the Graphite web docs for more information on the expectation of this function.