grafana/k6 · error

got from loki

Error message

got %d from loki: %s

What it means

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).

Solutions

  1. Inspect the response body in the error for the Loki server's reason
  2. Verify the Loki address and credentials/headers are correct
  3. Reduce msgMaxSize or batch volume if payloads are too large
  4. Check Loki server health and rate limits
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/log/loki.go:466 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/b86d42f99717dccf. Report an issue: GitHub.

Appendix: source

Thrown at internal/log/loki.go:466

		return err
	}
	req.GetBody = func() (io.ReadCloser, error) {
		return io.NopCloser(bytes.NewBuffer(body)), nil
	}

	req.Header.Set("Content-Type", "application/json")

	for _, header := range h.headers {
		req.Header.Add(header[0], header[1])
	}

	res, err := h.client.Do(req)

	if res != nil {
		if res.StatusCode >= 400 {
			r, _ := io.ReadAll(res.Body) // maybe limit it to something like the first 1000 characters?

			return fmt.Errorf("got %d from loki: %s", res.StatusCode, string(r))
		}
		_, _ = io.Copy(io.Discard, res.Body)
		_ = res.Body.Close()
	}

	return err
}

func mapEqual(a, b map[string]string) bool {
	if len(a) != len(b) {
		return false
	}
	for k, v := range a {
		if v2, ok := b[k]; !ok || v2 != v {
			return false
		}
	}

View on GitHub (pinned to 8d06114777)