Prometheus retention by time and size: when a single server needs a limit
A single Prometheus server keeps its data on local disk, and that disk grows with every series it ingests. Retention sets how much history Prometheus keeps, by time, by size, or by both, and it belongs in the configuration file. The storage docs give a default of 15 days, so a server that has never been tuned will keep 15 days of data regardless of how much disk it has. Local storage is single-node and not replicated or clustered, so when that disk fills, the server stops being a reliable monitor and the data cannot be recovered from a peer. Teams need this page when they first notice disk growth, when they move a server from a test environment to production, or when they add targets and cardinality faster than they planned for.
Start by checking three things in your environment: the disk size available to the data directory, the current ingestion rate, and the history your alerting and capacity reviews actually need. Confirm the retention period your compliance or operations teams require, since a time limit alone does not guarantee the disk will hold. A size limit caps the on-disk footprint, so the two settings work together: the server deletes the oldest blocks when either limit is reached. Keep headroom below the full disk, because the write-ahead log, compaction and any temporary files need space the retention settings do not count. The Prometheus storage documentation describes how blocks and the write-ahead log use disk, and it is the right reference when you size the limit.
Retention options and when each fits
This table compares time-based retention, size-based retention, and setting both, with the trade-off each carries and the team profile it suits. Read each row as a decision: the first column names the option, and the later columns show what you gain, what you risk and when to choose it. The main takeaway is that a size limit protects the disk, while a time limit protects the history you promised to keep.
| Option | Configuration field and flag | Trade-off | When it fits |
|---|---|---|---|
| Time-based retention only | storage.tsdb.retention.time in the configuration file (replaces --storage.tsdb.retention.time) | History length is predictable, but disk use grows with ingestion and can exhaust the volume if series volume rises | Teams with a fixed history requirement and a disk sized for it, such as a documented 30-day alerting or review window |
| Size-based retention only | storage.tsdb.retention.size in the configuration file (replaces --storage.tsdb.retention.size) | The disk is protected, but the oldest data is dropped without warning when the limit is reached, so history length varies | Teams with a fixed volume and no minimum history requirement, or where a capacity alarm is already in place |
| Both limits set together | storage.tsdb.retention.time and storage.tsdb.retention.size in the configuration file | Whichever limit is reached first removes data, so the effective history can be shorter than the time value | Teams that need a history target and also a hard disk ceiling, and that monitor how close usage runs to the size limit |
| Default behavior | Neither field set; the default retention is 15 days | Suitable for evaluation, but it does not account for your ingestion rate or disk size | Test environments only; set explicit limits before production use |
| Size limit below the volume capacity | storage.tsdb.retention.size set to a value that leaves headroom on the volume | Headroom absorbs compaction, the write-ahead log and sudden growth, but reduces usable history | Most production servers; confirm the headroom with your storage team and the storage docs sizing guidance |
| Flags versus configuration file | Command-line flags are deprecated; configuration fields are the supported path | Moving to the configuration file keeps settings in version control, but needs a reload or restart to apply | All new deployments and any server still passing the deprecated flags in its service definition |
Setting retention in the configuration file
This sequence sets time and size limits for Prometheus local storage in the configuration file, applies them without leaving the server short on disk, and confirms the effective values after the change. It is written for the engineer who owns the Prometheus host and the change window.
Review current disk use and ingestion
Check the total capacity of the volume that holds the Prometheus data directory, the space already used, and how much of that is Prometheus TSDB data versus other files. Then measure the ingestion rate, using the number of head series and samples appended per second from Prometheus's own metrics, and note how far back the oldest block reaches. Record these figures in the change ticket. The step is done when you have a current disk total, current usage, and a daily growth estimate you can defend, even if it is rough.
Choose time and size limits with headroom
Decide how many days of data the team needs, then compare that against the disk growth from the previous step. Set the size limit below the full capacity of the volume, leaving room for the write-ahead log, compaction work, and other files on the same disk. The Prometheus storage documentation advises keeping the size limit with headroom so the disk never fills, and many teams start in the 80 to 85 percent range of capacity as a working target, which you should confirm against your own environment. Whichever limit is reached first will trigger deletion, so write down which one you expect to bind. The step is done when the time value and size value are written in the change ticket with the reasoning.
Edit the retention fields in the configuration file
Open the Prometheus configuration file, usually named
prometheus.yml, and set the retention values under thestoragesection using thestorage.tsdb.retentionfields, such as the time and size settings described in the configuration reference. Do not add the--storage.tsdb.retention.timeor--storage.tsdb.retention.sizecommand-line flags, because those are deprecated in favor of the configuration file. If the startup command already contains those flags, remove them so the file is the single source of truth. Keep a copy of the previous file for rollback. The step is done when the file validates withpromtool check configand the diff shows only the intended retention change.Apply the change by restart or reload
Confirm how this Prometheus instance was started, then apply the new file. Reloading the configuration can pick up changes if the lifecycle endpoint is enabled through the
--web.enable-lifecycleflag, but the storage retention settings should be verified after applying, and a full restart is the safer path if you cannot confirm the reload took effect. Schedule the restart in a window where missed scrapes are acceptable, and ensure any alerting that depends on this server is aware. The step is done when the process has restarted or reloaded without errors in its log and the targets page shows scraping has resumed.Verify effective settings and disk usage
Confirm that Prometheus is running with the intended limits. Check the status page or the runtime information endpoint for the storage retention values in effect, and compare them with the file. Then check the Prometheus self-monitoring metrics for TSDB size and the oldest block timestamp, and confirm the disk usage on the volume is below the size limit you chose. Note the time when the next compaction or deletion cycle is expected to remove old blocks, and watch it once. The step is done when the effective values match the file and the disk usage sits within the planned headroom.
Document the settings and set disk alerts
Record the final time and size values, the date of the change, the reason for each value, and the rollback copy of the configuration file in the operations runbook. Add or confirm an alert on free disk space for the volume, so the team learns about growth before the limit is reached, and confirm the alert rule routes to a team that can act on it. Review the alert thresholds against the growth figures from the first step. The step is done when the runbook entry exists and the disk alert has been tested or confirmed to fire against a known threshold.
Changing retention at runtime without losing history
When disk usage climbs toward the limit, lowering retention is the fastest way to free space. Prometheus removes blocks that fall outside the new time or size limit, so space returns only after that cleanup runs, and it may not free space immediately. Treat the change as a controlled reduction and watch the disk while it happens.
- Lower the size limit first when the disk is filling: a size limit is the direct guard against a full disk, so set it below the free space you can safely use.
- Assume deleted history stays deleted: data removed by a lower limit cannot be restored from this server, so export or back up anything you need before the reload.
- Keep the time limit in view: the time limit still applies alongside the size limit, so review both values together.
- Watch free space after the reload: confirm the disk percentage falls over the following hours, and keep a fallback ready if it does not.
Before you change anything, confirm current disk usage, when the last compaction ran, and whether a remote write backlog is growing the write-ahead log.
Raising retention changes what the server keeps from now on, but it cannot bring back data that was already deleted. A higher limit only helps if the disk has room for the extra blocks, so the sizing calculation should come before the edit. Schedule a planned window and have the capacity figures ready before you change the file.
- Recalculate disk before raising: confirm the new limit still leaves headroom within the 80-85% guidance for disk use.
- Expect gaps in older history: data removed earlier will show as a gap in graphs and queries, and the new limit does not fill it.
- Set both limits deliberately: confirm which limit will bind first so the change does what you expect.
- Track growth after the change: ask the platform team to watch the disk growth curve for the days after the increase.
Before you finish, record the new values, the expected disk use at the new limit, and the date the team will review the growth curve.
Retention is read from the configuration file, so a runtime change means editing that file and then reloading the server. The HTTP reload path depends on the lifecycle endpoint. The reload and shutdown endpoints exist only when --web.enable-lifecycle is set, so confirm that flag in your startup configuration before you plan around it. The configuration reference lists the retention fields you will edit.
- HTTP reload with lifecycle enabled: validate the file with
promtooland then call the reload endpoint on the server. - Signal reload without the endpoint: confirm in the command-line documentation whether sending a hangup signal to the process reloads configuration in your version.
- Restart as the fallback: a restart works in every setup but interrupts scraping and rule evaluation for a short period.
- Restrict the lifecycle endpoint: it also allows shutdown, so limit network access to the server's management interface.
- Leave admin APIs off: deleting series requires
--web.enable-admin-api, which is destructive and is not needed to change retention.
Before the change, write down which reload path your deployment supports and test it on a non-production copy.
A saved file does not prove the running server accepted the change. Check what the server reports about its own configuration and storage, and compare that with the values you intended. Keep the evidence in your change record so the team can show the change took effect and when.
- Read the runtime information: the status API reports the storage settings the server is using, so confirm the retention field appears in your version.
- Compare the file with the loaded configuration: the values reported by the server should match the file you edited.
- Check the reload outcome: review the server logs for a successful reload message and the configuration reload metrics your version exposes.
- Watch the oldest sample time: after a lower limit, the earliest available timestamp should move forward once old blocks are removed.
After the reload, confirm the runtime values, the log entry, and the oldest timestamp, and save all three in the change record.
Most retention mistakes come from editing the wrong file or from assuming the disk will behave as expected. Settle these points before any change to a production server, and ideally test the same edit on a copy with similar data first.
- Record the owner and the reason: note who requested the change and whether it responds to disk pressure or is planned.
- Confirm the data you must keep: dashboards, alert history and compliance evidence may depend on older data, so check whether copies exist in long-term storage.
- Validate the file before reload: run
promtool check configon the edited file and fix any errors first. - Keep a rollback copy: store the previous configuration in version control so you can restore it quickly.
- Check the remote write path: a backlog during disk pressure can grow the write-ahead log, so confirm the remote write queue is healthy.
Before the window opens, confirm the on-call contact, the rollback steps and who will check the disk after the change.
How time and size limits trigger block deletion
The diagram starts with samples arriving from scrapes and entering the head block and the write-ahead log in memory. Completed two-hour blocks are written to disk, and the storage engine then checks the configured time and size limits. Whichever limit is reached first removes the oldest blocks. Check that the removal rule matches your retention settings and that disk headroom covers the period between checks.
How samples move from the head block to deletion under retention limits.
Security and operational risks when changing retention
Retention settings look like a small configuration change, but they touch stored data, the admin surface and the disk that every other feature depends on. The cards below cover the risks to review before and after you change retention, in roughly the order they tend to cause problems.
Lowering retention deletes data irreversibly
When you shorten the time or size limit, Prometheus removes older blocks once they fall outside the new limit. That data cannot be recovered from the server, so anything needed for an incident review, a capacity forecast or an audit trail must be exported first. Check which dashboards, recording rules and reports depend on history beyond the new window before you apply the change, and confirm whether a remote write or long-term store already holds a copy.
Storage docsAdmin APIs are disabled by default
The admin HTTP API is off unless you enable it. Turning on --web.enable-admin-api allows destructive operations, including deleting series, so it should never be added to a general-purpose server as a convenience. If retention work needs admin access, enable it for the shortest window, restrict who can reach the endpoint and record who made the change.
Lifecycle endpoints allow reload and shutdown
--web.enable-lifecycle exposes endpoints that reload the configuration and shut the server down. A retention change in the configuration file takes effect after a reload, so teams often enable this flag to avoid restarts. Anyone who can reach those endpoints can stop collection or apply unreviewed configuration, so restrict them to the deployment pipeline or to an internal network segment, and confirm that the reload path is covered by your change control.
Server and disk access must be controlled
Retention limits protect the disk, but the data on it is still operational history that can reveal hosts, services, customers and internal topology. Only administrators who manage the Prometheus host should be able to read or modify the data directory, and backups of that directory should carry the same access rules. Review file ownership and the service account that runs Prometheus after any change to storage paths.
Disk exhaustion before the limit is reached
A retention limit only holds if the disk has room for everything Prometheus writes before the limit is applied. Set alerts on free disk space and on the trend of disk usage well before the server reaches its limit, so you have time to act when ingestion grows faster than expected. Follow the 80 to 85 percent guidance for planning, and verify that the alert fires in a test before relying on it.
Retention changes need a verified rollback
A retention change is hard to reverse because deleted data does not return. Record the current values, the planned new values and the date of the change, and keep the previous configuration under version control so it can be restored. Ask whether the change can be tested on a staging server with a copy of the configuration before it is applied to production monitoring that teams use for on-call decisions.
Questions teams ask about Prometheus retention
How much does it cost to set Prometheus retention correctly?
Prometheus itself is free under Apache-2.0, so the cost of setting retention is the labor to size the disk, change the configuration and verify the result, plus the disk you provision. The one-time work covers measuring current ingestion and disk use and choosing limits. The recurring cost is disk growth as series count rises, and someone reviewing disk use after changes. A quote should list who does the sizing, who edits the configuration, how the change is tested on a non-production server, and whether ongoing review is included or handled as a retainer.
How long does it take to configure Prometheus retention by time and size?
The configuration change itself is small, but the time depends on how much you need to learn about your server first. The main drivers are how well you know current disk use and ingestion rate, whether the server runs on a host with other workloads, how many environments need the same policy, and how much change control applies. Teams with monitoring data already on hand and a single server can usually move quickly. Ask any partner to state the duration in the written scope after reviewing your environment.
What does our team need to provide for a retention change?
You need access to the Prometheus configuration file, a way to restart or reload the service, and access to the host or container where the data directory lives. You also need the disk metrics for that volume over a representative period, such as free space and ingestion trend, so limits can be set from real numbers. Provide the current storage.tsdb.retention.time and storage.tsdb.retention.size settings if they exist, plus any documented change windows and the owner who approves production changes.
Can our own team set Prometheus retention without outside help?
Yes. The change is a configuration edit: the retention values belong in the configuration file under the storage TSDB retention fields rather than the deprecated command-line flags. Your team can do it if it has someone who understands the disk layout, can measure ingestion and can test the restart safely. Outside help is most useful when several servers share a policy, when the disk is shared with other services, or when you want the change documented for audit. Check the current configuration reference before editing, since flag names and fields change between releases.
Why should Prometheus keep disk use below 80 to 85 percent?
Keeping disk use under roughly 80 to 85 percent leaves room for compaction, the write-ahead log and sudden increases in ingestion, which can need temporary space. Prometheus stores local data in two-hour blocks and a write-ahead log, and its storage documentation says local storage is not clustered or replicated, so a full disk puts the single server at risk. Set size limits with that headroom in mind, and alert before the volume fills rather than after. Confirm the exact behavior for your version in the storage documentation.
Does retention work replace moving to long-term storage?
No. Retention controls how long one local Prometheus server keeps data before deleting it. The default is 15 days, and local storage is not clustered or replicated. If you need months or years of metrics, a global view across servers, or high availability, you need a long-term store reached through remote write, such as Thanos, Grafana Mimir or VictoriaMetrics. Those projects add their own sizing, operating and cost questions, so treat retention as the first step and the storage design as a separate decision.
What happens to existing data when we change retention?
Lowering retention means older blocks become eligible for deletion, so data you may need for incident review or capacity trends can disappear. Before changing values, record what you need to keep, decide whether any of it must be exported or sent to long-term storage, and confirm your audit or compliance requirements for metric history. Ask the person making the change to document the old and new values, the date applied and the approver, so the reason for the change can be shown later.
How DeployOpen scopes Prometheus retention work
DeployOpen agrees the scope of retention work in writing before anything changes on a server. The agreed scope names the Prometheus servers involved, the retention targets each one must meet (how long data must stay queryable, how much disk the server may use, and which alerts must keep firing during a disk-pressure event), and the verification steps that show the targets were met. Retention is easy to change on one server and easy to get wrong across many, so the written scope also records which servers are excluded and why, such as servers that already send data to a long-term store and need a different plan.
The work runs on your own infrastructure, in your change windows, under your access controls. DeployOpen sets the time and size limits in the Prometheus configuration file, reviews the retention settings against the disk each server has, and tests the result on a staging copy before a production change. Verification covers a restart or reload, the reported block and disk usage over time, and a check that the alerts you rely on still evaluate. Your team keeps the configuration in its own version control, and the hand-over documents where each setting lives and how to change it safely.
Most engagements are fixed-scope, and ongoing work is available as a retainer. A retainer can cover Prometheus version upgrades, periodic review of disk usage as ingestion grows, and re-testing after changes to storage or retention. Before you request a quote, confirm the number of servers, the disk type and capacity on each, the current retention values, and whether any server forwards data through remote write, because those details define the written scope. DeployOpen does not publish prices, so the quote follows from that scope.

