{"record":{"id":"77556c02bee14bff","repo":"thanos-io/thanos","slug":"write-request-too-large-77556c","errorCode":null,"errorMessage":"write request too large","messagePattern":"write request too large","errorType":"http","errorClass":null,"httpStatus":413,"severity":"warning","filePath":"pkg/receive/handler_otlp.go","lineNumber":64,"sourceCode":"\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tunder, err := h.Limiter.HeadSeriesLimiter().isUnderLimit(tenant)\n\tif err != nil {\n\t\tlevel.Error(tLogger).Log(\"msg\", \"error while limiting\", \"err\", err.Error())\n\t}\n\n\t// Fail request fully if tenant has exceeded set limit.\n\tif !under {\n\t\thttp.Error(w, \"tenant is above active series limit\", http.StatusTooManyRequests)\n\t\treturn\n\t}\n\n\trequestLimiter := h.Limiter.RequestLimiter()\n\tif r.ContentLength >= 0 {\n\t\tif !requestLimiter.AllowSizeBytes(tenant, r.ContentLength) {\n\t\t\thttp.Error(w, \"write request too large\", http.StatusRequestEntityTooLarge)\n\t\t\treturn\n\t\t}\n\t}\n\n\treq, err := remote.DecodeOTLPWriteRequest(r)\n\tif err != nil {\n\t\tlevel.Error(h.logger).Log(\"msg\", \"Error decoding remote write request\", \"err\", err.Error())\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tmetrics, _, err := h.convertToPrometheusFormat(ctx, req.Metrics())\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ttotalSamples := 0","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/handler_otlp.go#L46-L82","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Reduce batch size at the exporter (lower batch timeout or batch size in the OTLP exporter config).","Increase the tenant's max request size limit in the receive request limiter configuration.","Split the export into multiple smaller requests client-side.","Check for intermediate proxies aggregating requests into oversized payloads."],"exampleFix":"// before\nexporter, _ := otlpmetrichttp.New(ctx, otlpmetrichttp.WithEndpoint(rcv))\n// after: smaller batches\nexporter, _ := otlpmetrichttp.New(ctx, otlpmetrichttp.WithEndpoint(rcv), otlpmetrichttp.WithTimeout(5*time.Second))\n// and set env OTEL_BLRP_MAX_EXPORT_BATCH_SIZE=512","handlingStrategy":"validation","validationCode":"if r.ContentLength >= 0 && r.ContentLength > maxSizeBytes { return http.StatusRequestEntityTooLarge }","typeGuard":null,"tryCatchPattern":"if resp.StatusCode == 413 { splitBatch(body, 2) /* split and resend */ }","preventionTips":["Cap exporter batch sizes well below the receive max_size_bytes","Compress payloads with gzip where accepted","Size limits to your largest expected batch"],"tags":["http","limits","thanos","payload-size"],"backgroundTag":"payload-too-large","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}