grafana/k6 · error
aggregation period is not allowed to have sub-second…
Error message
aggregation period is not allowed to have sub-second precision
What it means
Configuration guard in newCollector: the aggregation period has a fractional-second component (aggrPeriod != aggrPeriod.Truncate(time.Second)). The bucketing logic keys on whole seconds, so sub-second precision is rejected.
Solutions
- Round the aggregation period to whole seconds, e.g. '10s' instead of '10.5s' or '1500ms'
- Set K6_CLOUD_API_METRIC_PUSH_INTERVAL_AGGREGATION to a whole-second value
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at output/cloud/expv2/collect.go:70 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/35c21e32936ba922.
Report an issue: GitHub.
Appendix: source
Thrown at output/cloud/expv2/collect.go:70
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,
waitPeriod: waitPeriod,
}, nil
}View on GitHub (pinned to 01ffac6f24)