thanos-io/thanos · warning

write request too large

Error message

write request too large

What it means

HTTP 413 (Request Entity Too Large) returned by the OTLP ingest handler when the request's Content-Length exceeds the tenant's maximum allowed write request size, enforced via the Limiter's RequestLimiter.AllowSizeBytes. This protects receive nodes from oversized payloads that would consume too much memory during decoding and conversion.

Solutions

  1. Reduce batch size at the exporter (lower batch timeout or batch size in the OTLP exporter config).
  2. Increase the tenant's max request size limit in the receive request limiter configuration.
  3. Split the export into multiple smaller requests client-side.
  4. Check for intermediate proxies aggregating requests into oversized payloads.

Example fix

// before
exporter, _ := otlpmetrichttp.New(ctx, otlpmetrichttp.WithEndpoint(rcv))
// after: smaller batches
exporter, _ := otlpmetrichttp.New(ctx, otlpmetrichttp.WithEndpoint(rcv), otlpmetrichttp.WithTimeout(5*time.Second))
// and set env OTEL_BLRP_MAX_EXPORT_BATCH_SIZE=512
Defensive patterns

Strategy: validation

Validate before calling

if r.ContentLength >= 0 && r.ContentLength > maxSizeBytes { return http.StatusRequestEntityTooLarge }

Try / catch

if resp.StatusCode == 413 { splitBatch(body, 2) /* split and resend */ }

Prevention

When it happens

Trigger: Sending an OTLP ExportMetricsServiceRequest with Content-Length >= 0 whose byte size exceeds the tenant's configured maximum size (request.max_size_bytes / RequestLimiter size limit).

Common situations: Client batching too many metrics into one export; long-lived exporters accumulating large payloads when the receiver was down; receive configured with a small max request size; proxy compressing/decompressing into one huge body.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/77556c02bee14bff. Report an issue: GitHub.

Appendix: source

Thrown at pkg/receive/handler_otlp.go:64

		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	under, err := h.Limiter.HeadSeriesLimiter().isUnderLimit(tenant)
	if err != nil {
		level.Error(tLogger).Log("msg", "error while limiting", "err", err.Error())
	}

	// Fail request fully if tenant has exceeded set limit.
	if !under {
		http.Error(w, "tenant is above active series limit", http.StatusTooManyRequests)
		return
	}

	requestLimiter := h.Limiter.RequestLimiter()
	if r.ContentLength >= 0 {
		if !requestLimiter.AllowSizeBytes(tenant, r.ContentLength) {
			http.Error(w, "write request too large", http.StatusRequestEntityTooLarge)
			return
		}
	}

	req, err := remote.DecodeOTLPWriteRequest(r)
	if err != nil {
		level.Error(h.logger).Log("msg", "Error decoding remote write request", "err", err.Error())
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	metrics, _, err := h.convertToPrometheusFormat(ctx, req.Metrics())
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	totalSamples := 0

View on GitHub (pinned to 35b8b99117)