grafana/k6 · error
HTTP POST request failed: %w
Error message
HTTP POST request failed: %w
What it means
WriteClient.Store builds the snappy-compressed protobuf POST to the Prometheus remote-write endpoint; http.NewRequestWithContext failed here, which essentially only happens with an invalid/unparsable server URL in the output config. The remote-write sample batch is not sent and the output errors out.
Source
Thrown at internal/output/prometheusrw/remote/client.go:105
}
if c.cfg.BasicAuth != nil {
req.SetBasicAuth(c.cfg.BasicAuth.Username, c.cfg.BasicAuth.Password)
}
if len(c.cfg.Headers) > 0 {
req.Header = c.cfg.Headers.Clone()
}
req.Header.Set("User-Agent", "k6-prometheus-rw-output")
// They are mostly defined by the specs
req.Header.Set("Content-Encoding", "snappy")
req.Header.Set("Content-Type", "application/x-protobuf")
req.Header.Set("X-Prometheus-Remote-Write-Version", "0.1.0")
resp, err := c.hc.Do(req) //nolint:gosec
if err != nil {
return fmt.Errorf("HTTP POST request failed: %w", err)
}
defer func() {
err = resp.Body.Close()
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{View on GitHub (pinned to 01ffac6f24)
Solutions
- Verify the remote write URL and that Prometheus is reachable
- Check TLS settings (K6_PROMETHEUS_RW_INSECURE_SKIP_TLS_VERIFY, CA/cert config)
- Inspect the wrapped error for timeout or DNS details and fix network/firewall issues
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/output/prometheusrw/remote/client.go:105 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/e1df3584977e842d.
Report an issue: GitHub.