grafana/k6 · error

aggregation period is not allowed to be zero

Error message

aggregation period is not allowed to be zero

What it means

Configuration guard in newCollector (cloud output): the metric aggregation period was 0. The collector buckets samples by whole time periods, so a zero period is rejected when the output starts.

Solutions

  1. Set K6_CLOUD_API_METRIC_PUSH_INTERVAL_AGGREGATION to a non-zero whole-second duration
  2. Use a positive aggregation period such as '10s' in the cloud output configuration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at output/cloud/expv2/collect.go:67 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/0fcccd5b16e1ee63. Report an issue: GitHub.

Appendix: source

Thrown at output/cloud/expv2/collect.go:67

type collector struct {
	bq      bucketQ
	nowFunc func() time.Time

	aggregationPeriod time.Duration
	waitPeriod        time.Duration

	// we should no longer have to handle metrics that have times long in the past. So instead of a
	// map, we can probably use a simple slice (or even an array!) as a ring buffer to store the
	// aggregation buckets. This should save us a some time, since it would make the lookups and WaitPeriod
	// checks basically O(1). And even if for some reason there are occasional metrics with past times that
	// don't fit in the chosen ring buffer size, we could just send them along to the buffer unaggregated
	timeBuckets map[int64]map[metrics.TimeSeries]metricValue
}

func newCollector(aggrPeriod, waitPeriod time.Duration) (*collector, error) {
	if aggrPeriod == 0 {
		return nil, errors.New("aggregation period is not allowed to be zero")
	}
	if aggrPeriod != aggrPeriod.Truncate(time.Second) {
		return nil, errors.New("aggregation period is not allowed to have sub-second precision")
	}
	if waitPeriod == 0 {
		// TODO: we could simplify the expiring logic
		// just having an internal static logic.
		// Like skip only not closed buckets bucketEnd > now.
		return nil, errors.New("aggregation wait period is not allowed to be zero")
	}
	if waitPeriod != waitPeriod.Truncate(time.Second) {
		return nil, errors.New("aggregation wait period is not allowed to have sub-second precision")
	}
	return &collector{
		bq:                bucketQ{},
		nowFunc:           time.Now,
		timeBuckets:       make(map[int64]map[metrics.TimeSeries]metricValue),
		aggregationPeriod: aggrPeriod,

View on GitHub (pinned to 01ffac6f24)