Why Prometheus runs out of memory and when to act
When Prometheus restarts or is killed by the operating system for exceeding its memory limit, dashboards go blank and alerts stop evaluating until the server recovers. The cause is almost always memory held by active series, query load or remote write queues, and the right fix depends on which of the three dominates. Series churn and high cardinality inflate the head block in memory, long or heavy PromQL queries load samples into memory for the duration of each evaluation, and remote write queues buffer samples when the receiving system falls behind. Treating all three as one problem usually wastes time and can make the restarts worse.
This section sets up the rest of the page. The next sections walk through diagnosis, using the metrics Prometheus exposes about its own memory, series and query behavior, followed by the order of fixes: reduce cardinality first, then limit scrape and query load, then review remote write settings and memory limits such as GOMEMLIMIT. The order matters because raising memory limits on a server with unbounded series growth only delays the next crash. The page also covers how the container or host memory limit interacts with what Prometheus reports as its own usage.
Before changing anything, confirm several things in your own environment: the memory limit imposed by your host, container runtime or orchestrator, the version of Prometheus you run and whether it is a supported release, the number of targets and series you scrape, and whether remote write is enabled. Each of these determines which fix applies. Your team should also decide who can change scrape configuration and limits, because the fixes often touch several teams' exporters and dashboards. Confirm these facts first, then move through the diagnosis steps in order.
Where memory goes inside a Prometheus server
Memory use starts when scrape targets send samples to Prometheus. Each new series is held in the head block, which keeps active series in memory and records every write in the write-ahead log before the data is cut into two-hour blocks on disk. Queries read from both memory and disk, and when remote write is configured, samples wait in queues in memory until the external store accepts them. Check the points marked in the diagram, because each one is where a fix can act: scrape limits, relabeling, query limits, recording rules and remote write tuning. This is a simplified model, not a full map of Prometheus internals.
A simplified model of where a Prometheus server holds data in memory and where fixes apply.
How series churn and cardinality fill the head block
The head block is the part of the Prometheus TSDB that holds the most recent samples in memory before they are compacted into two-hour blocks on disk. Each active series has an entry in the head, and every new series adds to the memory the process needs. Samples are first appended to the write-ahead log, so the head can be rebuilt after a restart, but the in-memory index and series set still have to fit in the memory available to the process. The Prometheus storage docs describe this layout, and it is the first place to look when memory climbs without a matching rise in scrape volume.
Memory use depends on how many distinct series exist at the same time, not only on how many samples arrive per second. A metric with labels such as user ID, request path or container ID multiplies into many series, and each unique label combination is held in the head until it is compacted and no longer active. Series churn adds a second cost: when pods, jobs or short-lived containers are replaced, their series stop receiving samples but remain in the head for a period, while new series with new label values are created. A deployment that adds a label with a new value on every build can therefore double the working set within a short window, which is why a single bad release can move memory use faster than a steady traffic increase would.
Before changing any setting, confirm which series are driving the growth. Compare the head series count with the number of targets and expected series per target, and check whether the increase lines up with a deployment, a new scrape job or a label change. The cardinality and scrape limit pages in this group cover how to find the offending metrics and cap them, so this page does not replace those steps. Its role is to connect what the head block is holding to the restarts and OOM kills described in the sections that follow.
Which memory fix matches which cause
This table pairs each common cause of Prometheus memory growth with the signal that confirms it, the fix to try first and the trade-off that fix brings. Read it by matching the signal you see to a row, then follow the linked operations page for the detailed steps. Work the rows in the order the table gives, because cardinality and churn usually sit underneath the others.
| Cause | Signal to check | Fix | Trade-off |
|---|---|---|---|
| High cardinality from labels | Head series count grows steadily, and a few metric names hold most series | Find the offending labels, then drop or relabel them and change instrumentation (see finding high cardinality) | Dropped labels lose the per-value breakdown that some dashboards and alerts rely on |
| Series churn from short-lived targets | Series count rises and falls with each deploy or job run, and head series keep turning over | Relabel unstable labels such as pod or instance IDs where possible, and set scrape limits per job (see protecting Prometheus with limits) | Limits can drop data from a legitimate burst, so teams must agree on the caps |
| Expensive queries and dashboards | Memory spikes line up with dashboard refreshes or large range queries in the query log | Add query timeouts and sample limits, then move heavy expressions into recording rules (see fixing slow PromQL queries) | Recording rules add evaluation load and storage, and need maintenance when dashboards change |
| Remote write backlog | Remote write queues grow, shards stay at maximum, and memory rises while the remote endpoint is slow | Tune queue and shard settings, and check the remote endpoint's health and capacity (see scaling and long-term storage) | Larger queues hold more samples in memory and delay data reaching long-term storage |
| Memory limits set too low for the workload | The process restarts at the same memory level under normal load, with no clear series or query growth | Raise the container or host memory limit, and review GOMEMLIMIT against the limit (see storage and sizing) | More memory cost, and a higher limit only hides growth that will return without the other fixes |
Signals that point to each memory cause
Prometheus memory use follows a few distinct drivers, and each leaves a different trace. Check the series count, the series churn, the timing of restarts and the remote write queues before changing any setting, because the same crash can come from several sources. Exact metric names differ between versions, so confirm them against the running release on the status and metrics pages.
Head series growth
The head block holds every active series in memory, so a steady rise in active series raises the baseline heap directly. Check the prometheus_tsdb_head_series metric over days and compare the rise against the timing of new exporters, new label values or new scrape jobs. Confirm whether the growth is a step change tied to one deployment or a slow climb that tracks traffic. Pair the trend with the container memory graph to see whether the two move together.
Series churn after deployments
Pods and short-lived jobs create new series with new label values, and the old series stay in the head block until they age out. Check the prometheus_tsdb_head_series_created_total and prometheus_tsdb_head_series_removed_total counters, and look for a spike in creations that lines up with rollouts. Confirm whether a label such as a pod name, container ID or request path changes on every deploy. A high churn rate can keep memory elevated even when the number of live series looks stable.
Heavy query during restart window
A PromQL query that loads many series or samples can allocate a large amount of memory in a short burst, and a restart that begins while that query runs can look like a crash loop. Check the query activity metrics and the query log if enabled, and compare restart times with dashboard refresh schedules and alert rule evaluations. Confirm which panels or rules run over wide ranges with broad regex matchers. Note the exact query timeout and sample limit settings in the running configuration.
Remote write queues growing during receiver outage
When the remote storage receiver is slow or unavailable, samples queue in memory and the queue grows until the container hits its limit. Check the prometheus_remote_storage_* queue metrics for pending samples, retries and shards, and confirm whether the growth starts when the receiver's own errors begin. Compare the timing of the memory climb with the receiver's outage window. Ask whether the queue settings were sized for the expected outage duration.
Restarts clustered at compaction
Compaction reads and rewrites blocks, which adds memory and disk work on top of the normal head load. If restarts cluster around compaction cycles, the process is likely near its limit at peak, not leaking. Check the compaction duration and count metrics, and correlate restart timestamps with them. Confirm whether the host has enough headroom for compaction on top of the head, because the margin can be small on a node sized only for steady state.
Container limit hit without series growth
When memory reaches the container limit while series counts stay flat, the cause is often a limit set below what the process needs, or memory held by queries and caches rather than series. Check the container working set against the process resident memory and the Go runtime metrics, and confirm the memory limit configured for the container. Review whether GOMEMLIMIT is set and whether it sits below the container limit. Compare these values with the version's documented guidance before adjusting anything.
Prometheus storage docsWhat GOMEMLIMIT and container memory limits do and do not fix
Two different settings decide when a Prometheus process dies, and they do different jobs. GOMEMLIMIT is a soft target for the Go runtime: as heap use approaches it, the garbage collector runs more often and works harder to stay under the number you set. A container memory limit is enforced by the kernel. When the process's resident memory exceeds the cgroup limit, the kernel kills it, which shows up as an OOM kill and a restart. Tuning GOMEMLIMIT can make Prometheus spend more CPU on collection before it runs out of room, but it cannot make the process need less memory. Set the Go limit somewhat below the container limit so the runtime has room to act before the kernel intervenes, and confirm the exact behavior for your version in the release notes on the Prometheus GitHub releases page before you copy any value from a blog post or older runbook.
A higher container limit or a tighter GOMEMLIMIT can delay the next OOM, but it does not reduce the series, label sets or queries that are driving memory growth. If head series are climbing because of a new label, a churning deployment or an expensive dashboard, the same workload will fill the larger allowance a few days later. Treat any limit change as a temporary measure to stop restarts while you find the cause, and record the before and after memory and series counts so the change can be reversed. Also check whether the node itself is overcommitted, since a limit that is higher than the memory the node can actually provide will still end in a kill.
Before you raise any limit, ask your platform team to confirm three things: the GOMEMLIMIT behavior documented for the Prometheus release you run, the container limit actually applied to the pod or unit (not the value in the manifest template), and whether a Kubernetes or systemd restart policy is hiding repeated kills. If those checks show the workload is stable at a higher ceiling, you have bought time to work through the series and query fixes in the sections that follow. If memory keeps climbing past any ceiling you can justify, the limit is not the fix, and the workload needs to shrink.
Setting up memory observation before the next crash
This sequence gives you a baseline of the running version, memory use, series counts and restart causes, so the next out-of-memory event can be traced to a specific cause instead of guessed at.
Confirm the running version and support status
Check the exact Prometheus version on each server, including patch level, and compare it with the release cycle page to see whether that minor line still receives bug fixes and whether it is an LTS line. Your team or the implementation partner records the result in the runbook. Done when every instance has a version and support status written next to its name, and any unsupported line has an upgrade item in the backlog. Confirm the current release list on the GitHub releases page before deciding.
Enable self-monitoring of memory and series
Confirm that Prometheus scrapes its own metrics endpoint, which exposes process memory and TSDB series figures. Use a job that scrapes each Prometheus instance and check the target page for the job as up. Then query the process memory metric and the head series metric in the expression browser. Done when both series return values for every instance, with a timestamp close to the current time. If they do not, fix the scrape job before going further, because every later step depends on these numbers.
Record the container memory limit
Write down the memory limit and request that the orchestrator or service manager applies to each Prometheus container or unit, and the heap-related environment settings in use, including whether GOMEMLIMIT is set. Your platform engineers capture these from the deployment manifest or unit file, not from memory. Done when the limit for each instance is in the runbook and matches what the running process reports, so you know whether the process is near its ceiling or far below it.
Capture the restart reason in orchestrator logs
Find how the last restart was recorded: the container runtime, Kubernetes pod status or systemd journal should show whether the process exited because it exceeded its memory limit. Note the exit code and timestamp. Store a copy of these events in a location that survives pod or host rotation. Done when you can point to a logged reason for each restart in the past period, or you have recorded that no reason was logged, which is itself a finding to resolve with the platform team.
Capture TSDB status before and after restarts
Use the TSDB status endpoint on the running instance and save its output, including head series count and the top series counts by metric name and label pair. Repeat the capture right after each planned restart and again once the server has been running steadily. Keep the files with timestamps. Done when you have at least one pre-restart and one post-restart capture per instance, which lets you compare the composition of head series rather than only the total.
Set a baseline for head series
Using the saved TSDB status captures and the self-monitoring metrics, record the normal range of head series and memory for each instance under typical load. Chart the head series count over time in your dashboard so that sudden growth stands out. Your team sets the alert threshold based on this observed baseline rather than a published value. Done when the baseline is documented and a dashboard panel shows it, so any later jump can be compared against a known starting point.
Operational risks while memory is unstable
Recovery work on a crashing Prometheus tempts teams to loosen controls: open admin endpoints, change scrape configuration in place, or move data around without a copy. Each of these can turn a memory incident into lost history or an exposed server. The cards below cover the risks to confirm before anyone touches the running instance.
Admin APIs left enabled
The admin HTTP APIs are disabled by default, and the --web.enable-admin-api flag enables destructive operations such as series deletion. Teams sometimes switch it on during an incident and forget to switch it off. Confirm the flag is unset on every instance after the incident, and record who enabled it and when. The security model describes which endpoints this flag exposes.
Security modelLifecycle endpoints during troubleshooting
The --web.enable-lifecycle flag enables reload and shutdown endpoints. A shutdown request during a crash loop can interrupt head block writes, and a reload can apply a configuration nobody reviewed. Confirm whether lifecycle endpoints are enabled, who can reach them, and whether any change window is recorded before a restart.
Security modelWeb API exposed while debugging
Engineers often widen network access to the Prometheus UI or API to run queries from a laptop or a shared bastion. Prometheus has no built-in single sign-on and no built-in CSRF protection on mutating endpoints, so an open port is an open control surface. Confirm the listener is bound only to the networks that need it, and that an authenticating reverse proxy or TLS sits in front if access is widened.
Data directory deleted before backup
Clearing the data directory is a common reflex when the TSDB will not start, but it removes the blocks and write-ahead log that a later recovery may need. Local storage is a single node with no replication, so the directory is the only copy unless remote storage holds the same samples. Confirm a full copy of the data directory exists, with its size and owner recorded, before any file is moved or removed.
Scrape changes without review
Raising sample limits, adding targets or changing relabeling during an incident can add series faster than memory can absorb them. Dropping a job or altering a relabel rule can also end a series history that dashboards and alerts depend on. Confirm each configuration change is reviewed, versioned and tied to a named owner, so the team can tell which change moved the series count.
Remote write receiving more data
Raising remote write throughput or enabling a new destination during recovery can send far more samples than the receiving system was sized for. The receiver then rejects writes, queues grow in Prometheus, and memory rises again. Confirm the expected sample rate with the receiving team, the queue settings in use, and the retention and storage budget on the far side before enabling more traffic.
What to confirm in your environment before setting limits
The first fix for an out-of-memory crash depends on facts about your setup, so confirm them before you change any limit. Start with the exact Prometheus version and the release line it belongs to. Prometheus minor releases receive bug fixes for only a limited period, and the long-term support lines are documented on the Prometheus release cycle page. If you are running a minor release that is past its support window, upgrading may be the fix that comes before any tuning, and the version also tells you which memory-related behavior applies to your server.
Next, record how the server is deployed. Confirm whether it runs as a bare process, a systemd service, a container or a pod, and what memory limit the platform enforces. A container or Kubernetes memory limit that is lower than what Prometheus needs will produce kernel OOM kills that look like crashes in the logs, and the value of GOMEMLIMIT only makes sense relative to that ceiling. Also confirm the storage volume: its type, its throughput under load and how much free space it has. Compaction and WAL replay both consume disk and time, so a slow volume can make restarts take long enough to look like a second failure.
Then measure the workload. Count the scrape targets, estimate how often pod or instance identities change (churn), and find out which teams add scrape jobs or labels. Ask who runs queries and which dashboards and alert rules execute most often, because heavy range queries are a common source of memory spikes. Finally, confirm whether remote write is enabled and to which endpoints, since its queues and buffers add memory use that does not appear in the local series count. Write these answers down with their sources. They decide whether cardinality, query load or remote write is the first thing to fix, and they tell you which numbers you still need to collect before you set any limit.
Questions teams ask about Prometheus memory crashes
What drives the cost of fixing Prometheus out-of-memory crashes?
The cost depends on how many series the server holds, how many teams and dashboards query it, and how much of the estimate is already known from your own data. Prometheus is open source under Apache-2.0, so there is no license fee to pay. You pay for the server and storage, the time your own engineers spend, and any outside help. Ask any partner for a written scope that lists the diagnosis steps, the changes to scrape configs and rules, the verification, and the handover, along with what is one-time work and what recurs, such as upgrades or ongoing testing. Quotes follow from that written scope.
How long does diagnosing a Prometheus memory problem take?
The duration depends on scope, not on a fixed number. The main variables are how many targets and scrape jobs feed the server, how many recording and alerting rules run, how many dashboards and users run heavy queries, and whether the server already exposes the TSDB status data needed to find the cause. A small, well-instrumented server with one suspect job usually goes faster than a shared server with many teams and no history. Ask for the diagnosis to be scoped by target count, query sources and the time window you need to review before work starts.
Can our team fix Prometheus memory crashes without outside help?
Yes, many teams can, especially if they have an engineer who knows PromQL and has access to the server logs and configuration. The usual path starts with finding the source of new series, then reviewing heavy queries, then tuning limits and retention. The harder part is usually organizational: changing how teams label metrics or deploy instrumentation. Outside help makes sense when no one has time to own the investigation, when the server is shared by several teams, or when the fix has to be documented for auditors. Your team should be able to explain each change and roll it back.
What access and information does a memory fix need from us?
The work needs read access to the Prometheus server and its logs, the ability to query the status endpoints, and copies of the scrape configs, relabeling rules and alerting rules. It also needs the dashboards and their query history, the Kubernetes or host metadata that shows where targets come from, and the memory and restart history from the host or orchestrator. Admin APIs should stay disabled unless someone approves a temporary change, and any credentials should be handled under your own access policy. Confirm the exact access list, the change window and the people who approve changes in the written scope.
Does remote storage remove Prometheus memory problems?
No. Remote write and remote read let Prometheus send samples to external long-term storage, which can move history out of the local database, but the local server still holds series in memory and still runs queries. Remote write also adds its own buffers and network work, so it can add memory pressure if the receiver falls behind. Cardinality and heavy queries cause the same crashes whether or not remote storage is in use. Treat remote storage as a separate design decision, and confirm the memory impact with the specific receiver you plan to use.
Does restarting Prometheus lose monitoring data?
A clean restart normally keeps stored data, because Prometheus writes samples to its local time series database in two-hour blocks and records recent samples in a write-ahead log. The risk comes from the restart itself: samples that were only in memory or in the WAL can be affected if the process is killed mid-write, and an unclean shutdown during a crash loop can leave damaged blocks. Back up the data directory before changing storage or deleting anything, and confirm your retention settings, which default to 15 days. Gaps in data during the outage will remain, so check which alerts depended on that window.
Which Prometheus memory fixes should we apply first?
Apply the fixes that reduce risk without changing what the business sees. In practice that means confirming the crash cause with the server's own status data, then limiting the scrape job or team that adds the most series, then reviewing the queries that run over long ranges. Changing retention or hardware usually comes after those steps, because it treats the symptom. Record the memory and series count before and after each change so you can show the effect. Confirm the order with your platform owner before you apply changes to production.
How DeployOpen scopes and delivers Prometheus memory work
DeployOpen treats Prometheus memory problems as a sequence: confirm what the server is holding, fix the causes in order, then leave the team with limits and runbooks they can operate. Work is delivered inside your infrastructure, against a written scope agreed before any change is made.
How we scope
- Engagements are fixed-scope, with the OOM investigation, fixes and deliverables agreed in writing before work starts.
- The scope names the Prometheus servers, scrape jobs, remote write targets and dashboards in question, and what evidence you will receive.
- Scope lists which changes are in bounds, such as relabeling or limits, and which need your application teams or a memory increase decision.
How we build
- We review restart history, container memory limits and GOMEMLIMIT settings alongside series counts and the TSDB status data.
- We apply fixes in the order the evidence supports, testing each change against a restart or memory trend before the next one.
- Changes to scrape configuration, rule files and remote write are tested in a non-production copy where your environment allows it.
How we hand over
- You receive the diagnostic queries, configuration changes and a record of what each change did to memory and series counts.
- Documentation covers the limits in place, owners for each scrape job, and the thresholds that should trigger a review.
- We walk your platform team through the runbook so they can repeat the diagnosis without us.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer, scoped separately from the original work.
- Retainers can cover Prometheus version planning, including reviewing release notes for the LTS line you run.
- Confirm with us during scoping how alert coverage and capacity reviews will be handled after the engagement closes.

