{"record":{"id":"e1df3584977e842d","repo":"grafana/k6","slug":"http-post-request-failed-w","errorCode":null,"errorMessage":"HTTP POST request failed: %w","messagePattern":"HTTP POST request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/prometheusrw/remote/client.go","lineNumber":105,"sourceCode":"\t}\n\tif c.cfg.BasicAuth != nil {\n\t\treq.SetBasicAuth(c.cfg.BasicAuth.Username, c.cfg.BasicAuth.Password)\n\t}\n\n\tif len(c.cfg.Headers) > 0 {\n\t\treq.Header = c.cfg.Headers.Clone()\n\t}\n\n\treq.Header.Set(\"User-Agent\", \"k6-prometheus-rw-output\")\n\n\t// They are mostly defined by the specs\n\treq.Header.Set(\"Content-Encoding\", \"snappy\")\n\treq.Header.Set(\"Content-Type\", \"application/x-protobuf\")\n\treq.Header.Set(\"X-Prometheus-Remote-Write-Version\", \"0.1.0\")\n\n\tresp, err := c.hc.Do(req) //nolint:gosec\n\tif err != nil {\n\t\treturn fmt.Errorf(\"HTTP POST request failed: %w\", err)\n\t}\n\tdefer func() {\n\t\terr = resp.Body.Close()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\t_, err = io.Copy(io.Discard, resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn validateResponseStatus(resp.StatusCode)\n}\n\nfunc newWriteRequestBody(series []*prompb.TimeSeries) ([]byte, error) {\n\tb, err := proto.Marshal(&prompb.WriteRequest{","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/prometheusrw/remote/client.go#L87-L123","documentation":"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.","triggerScenarios":"Thrown at internal/output/prometheusrw/remote/client.go:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}