grafana/k6 · error
encoding series as protobuf write request failed: %w
Error message
encoding series as protobuf write request failed: %w
What it means
proto.Marshal failed while serializing the collected TimeSeries into a prompb.WriteRequest. This is an internal serialization failure of the Prometheus remote write output, not a configuration problem.
Source
Thrown at internal/output/prometheusrw/remote/client.go:127
if err != nil {
panic(err)
}
}()
_, 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
- Retry the test run; transient marshal failures are not expected
- Report a bug to k6 with the script and metrics that triggered it
- Reduce custom labels/series complexity to isolate the cause
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/output/prometheusrw/remote/client.go:127 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/4c31952040c13c2b.
Report an issue: GitHub.