{"record":{"id":"b86d42f99717dccf","repo":"grafana/k6","slug":"got-d-from-loki-s","errorCode":null,"errorMessage":"got %d from loki: %s","messagePattern":"got (.+?) from loki: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/log/loki.go","lineNumber":466,"sourceCode":"\t\treturn err\n\t}\n\treq.GetBody = func() (io.ReadCloser, error) {\n\t\treturn io.NopCloser(bytes.NewBuffer(body)), nil\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tfor _, header := range h.headers {\n\t\treq.Header.Add(header[0], header[1])\n\t}\n\n\tres, err := h.client.Do(req) //nolint:gosec\n\n\tif res != nil {\n\t\tif res.StatusCode >= 400 {\n\t\t\tr, _ := io.ReadAll(res.Body) // maybe limit it to something like the first 1000 characters?\n\n\t\t\treturn fmt.Errorf(\"got %d from loki: %s\", res.StatusCode, string(r))\n\t\t}\n\t\t_, _ = io.Copy(io.Discard, res.Body)\n\t\t_ = res.Body.Close()\n\t}\n\n\treturn err\n}\n\nfunc mapEqual(a, b map[string]string) bool {\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\tfor k, v := range a {\n\t\tif v2, ok := b[k]; !ok || v2 != v {\n\t\t\treturn false\n\t\t}\n\t}\n","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/log/loki.go#L448-L484","documentation":"The Loki push endpoint returned an HTTP status code of 400 or higher; the response body is included verbatim. This indicates the Loki server rejected the batch of log entries (bad payload, auth failure, rate limit, or server error).","triggerScenarios":"Thrown at internal/log/loki.go:466 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the response body in the error for the Loki server's reason","Verify the Loki address and credentials/headers are correct","Reduce msgMaxSize or batch volume if payloads are too large","Check Loki server health and rate limits"],"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-14T05:17:10.506Z"}