{"record":{"id":"cc19b25775f8e1af","repo":"vectordotdev/vector","slug":"out-of-memory","errorCode":null,"errorMessage":"Out of memory","messagePattern":"Out of memory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/prometheus/remote_write/request_builder.rs","lineNumber":42,"sourceCode":"    ) -> io::Result<(usize, GroupedCountByteSize)> {\n        let mut byte_size = telemetry().create_request_count_byte_size();\n\n        let mut time_series = collector::TimeSeries::new();\n        let len = input.len();\n        for metric in input {\n            byte_size.add_event(&metric, metric.estimated_json_encoded_size_of());\n\n            time_series.encode_metric(\n                self.default_namespace.as_deref(),\n                &self.buckets,\n                &self.quantiles,\n                &metric,\n            );\n        }\n        let request = time_series.finish();\n\n        let mut out = BytesMut::with_capacity(request.encoded_len());\n        request.encode(&mut out).expect(\"Out of memory\");\n        let body = out.freeze();\n\n        write_all(writer, len, body.as_ref())?;\n\n        Ok((body.len(), byte_size))\n    }\n}\n\n#[derive(Clone)]\npub(super) struct RemoteWriteRequest {\n    pub(super) request: Bytes,\n    pub(super) tenant_id: Option<String>,\n    finalizers: EventFinalizers,\n    metadata: RequestMetadata,\n}\n\nimpl Finalizable for RemoteWriteRequest {\n    fn take_finalizers(&mut self) -> EventFinalizers {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sinks/prometheus/remote_write/request_builder.rs#L24-L60","documentation":"The Prometheus remote_write request builder encodes a protobuf TimeSeries into a BytesMut with prost's encode() and unwraps with expect(\"Out of memory\"). Per prost, encode only fails when the underlying buffer cannot grow (allocation failure), so the message asserts memory exhaustion, not malformed metrics. Metrics were already validated by encode_defaults above.","triggerScenarios":"prost encode() fails during remote_write request finalization when BytesMut cannot reserve encoded_len bytes — i.e., the process cannot allocate the needed memory for a large batch of time series.","commonSituations":"Memory-constrained containers hitting cgroup limits with very large metric batches; extremely high-cardinality Prometheus metrics producing huge remote_write payloads; OOM-adjacent conditions.","solutions":["Reduce batch size (batch.max_events / batch_timeout) in the prometheus remote_write sink config to shrink each encoded payload.","Increase the container/host memory limit available to Vector.","Lower metric cardinality before the sink (drop/relabel high-cardinality series via VRL or the source).","Check for memory leaks or contention in the process (RSS near the limit) and upgrade Vector."],"exampleFix":"// before (vector.yaml)\nsinks:\n  prometheus_remote:\n    batch:\n      max_events: 100000\n\n// after\nsinks:\n  prometheus_remote:\n    batch:\n      max_events: 1000","handlingStrategy":"validation","validationCode":"// vector.yaml — cap batch size so encoded protobuf payloads stay small\nsinks:\n  prometheus_remote:\n    batch:\n      max_events: 1000\n      timeout_secs: 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep batch.max_events modest for high-cardinality metric streams.","Right-size container memory for Vector workloads.","Reduce metric cardinality upstream (drop/relabel).","Monitor Vector RSS memory usage against limits."],"tags":["rust","panic","memory","prometheus","protobuf"],"backgroundTag":"out-of-memory","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}