grafana/k6 · error
the protobuf message is too large to be handled by Snappy en
Error message
the protobuf message is too large to be handled by Snappy encoder; size: %d, limit: %d
What it means
The marshaled protobuf WriteRequest is so large that its Snappy-encoded length would overflow uint32, so the batch can never be sent as one remote-write request. The reported size exceeds the ~4GiB encoder limit.
Source
Thrown at internal/output/prometheusrw/remote/client.go:130
}()
_, err = io.Copy(io.Discard, resp.Body)
if err != nil {
return err
}
return validateResponseStatus(resp.StatusCode)
}
func newWriteRequestBody(series []*prompb.TimeSeries) ([]byte, error) {
b, err := proto.Marshal(&prompb.WriteRequest{
Timeseries: series,
})
if err != nil {
return nil, fmt.Errorf("encoding series as protobuf write request failed: %w", err)
}
if snappy.MaxEncodedLen(len(b)) < 0 {
return nil, fmt.Errorf("the protobuf message is too large to be handled by Snappy encoder; "+
"size: %d, limit: %d", len(b), math.MaxUint32)
}
return snappy.Encode(nil, b), nil
}
func validateResponseStatus(code int) error {
if code >= http.StatusOK && code < 300 {
return nil
}
return fmt.Errorf("got status code: %d instead expected a 2xx successful status code", code)
}
View on GitHub (pinned to 01ffac6f24)
Solutions
- Reduce the number of time series per batch (lower K6_PROMETHEUS_RW_MAX_BATCH_SIZE or the equivalent)
- Reduce metric cardinality: fewer custom tags/labels in the script
- Shorten the flush interval so batches are smaller
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/output/prometheusrw/remote/client.go:130 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/0808c838db81713f.
Report an issue: GitHub.