If you're using Prometheus for monitoring, you've probably encountered its storage limitations. By default, Prometheus only keeps your metrics for 15 days. This works fine when you're just starting out, but quickly becomes a problem when looking at long-term trends or meeting compliance requirements.
This guide will show you exactly how to increase your Prometheus retention period, so you can keep your valuable monitoring data for weeks, months, or even years.
Prometheus stores all your metrics in a time-series database on disk. The retention setting simply controls how long Prometheus keeps this data before automatically deleting it to free up space.
Prometheus controls data retention with two main settings:
The default is 15 days, regardless of size. When you hit either the time or size limit, Prometheus starts removing older data to make room for new metrics. This works for immediate needs but falls short when you need historical data.
Keeping your metrics longer gives you several significant benefits. You can spot gradual performance trends you'd miss with just two weeks of data. You'll make better infrastructure decisions based on actual historical usage.
You can find weekly, monthly, or seasonal patterns in your systems' behavior. If you have compliance requirements, longer retention helps you meet them. And when troubleshooting complex issues, having months of historical context enables you to find the root cause faster.
For example, a memory leak that increases usage by just 1% per day might seem harmless in a two-week window, but over 60 days, you'd see it's headed for a serious problem.
Before making changes, check your current setup. The fastest way is to query the Prometheus API:
You can also check your Prometheus config file or command-line arguments:
Note that these commands might return empty results if you haven't explicitly set retention options. This doesn't mean there's an error – it just indicates Prometheus is using its default 15-day retention period.
Or visit the Prometheus web interface and go to Status > Configuration to see all current settings:
Even in the web interface, you might not see storage settings listed if you haven't configured them explicitly. In this case, Prometheus is using the default values.
Prometheus doesn’t provide a central configuration file for retention settings—instead, these flags need to be passed directly to the Prometheus process. How you do that depends on how Prometheus is deployed.
Below, we’ll walk through how to increase retention time in three common deployment environments: systemd-based setups, Docker Compose, and Kubernetes.
Each method involves passing the --storage.tsdb.retention.time flag to your Prometheus process with your desired retention value (e.g. 90d for 90 days).
If you installed Prometheus directly on a server and manage it with systemd, you’ll need to update the systemd service definition to include the new retention time.
Open the Prometheus service file:
Find the ExecStart line and add or update the retention flag:
Save the file and reload systemd:
Restart Prometheus:
Verify your changes took effect:
If you’re running Prometheus using Docker Compose, you must update the command section in your docker-compose.yml file to pass the retention time flag.
Open your docker-compose.yml file:
Update the Prometheus service section:
Apply the changes:
Check that it worked:
If you're running Prometheus in Kubernetes, the retention time must be passed as an argument to the Prometheus container—usually within a StatefulSet or Deployment managed by your monitoring stack (like kube-prometheus-stack).
Edit your Prometheus StatefulSet:
Add the retention flag to the container args:
Save changes and Kubernetes will automatically update your pods.
Verify the new settings:
When you increase retention, you need more disk space. Here's how to figure out how much you'll need.
You can estimate your storage needs with this simple formula:
For example, if you collect 10,000 samples per second at around 2 bytes per sample (compressed):
For 90 days of retention, you'd need approximately:
To check your actual ingestion rate:
To maximize storage efficiency with longer retention:
Enable TSDB compression to reduce disk usage by 50-70%:
Create recording rules to pre-aggregate metrics that you frequently query. This reduces the number of raw time series you need to store.
Consider increasing the scrape interval for metrics that don't need high-resolution sampling.
Set up an alert for when storage is running low:
If you need to keep metrics for months or years, consider using remote storage options.
While solutions like Thanos, or Corter can handle years of data, Better Stack offers a more straightforward approach to remote storage with excellent performance.
Better Stack's Telemetry platform makes setting up remote storage for your Prometheus metrics remarkably easy. You can forward metrics from your existing Prometheus instance using Vector with Prometheus Remote-Write.
First, install Vector on your system:
Configure Vector to receive Prometheus metrics and forward them to Better Stack:
Update your Prometheus configuration to write to Vector:
Restart Vector and reload Prometheus:
This approach lets you keep your recent data in Prometheus for fast local queries while sending everything to Better Stack for long-term storage and analysis. Better Stack handles all the complexities of storage optimization, downsampling, and query efficiency, so you don't have to manage a complex storage infrastructure.
Unlike traditional setups with Thanos that require configuring object storage like S3:
Better Stack eliminates this complexity with a fully managed solution that scales with your needs.
Here are solutions to common problems you might face when increasing retention.
If your disk usage shoots up after increasing retention:
Solution: Set up monitoring to predict storage growth and automatically expand volumes before they fill up.
If queries covering months of data become painfully slow:
Solution: Create recording rules for common queries and consider using remote storage with downsampling for historical data.
If you see storage compaction errors in logs:
Solution: Ensure you have at least 30% free space on your storage volume for TSDB compaction to work properly.
Managing retention isn't just about setting a number of days—it's about balancing performance, cost, and usability. These proven practices help keep your Prometheus setup efficient, reliable, and ready for long-term insights:
Increasing Prometheus retention gives you powerful insights from longer-term data analysis. It helps you spot trends, plan capacity more effectively, and troubleshoot complex issues with better context.
Your retention strategy should match your specific needs, compliance requirements, and available resources. Whether you choose to extend local storage or implement remote storage, the key is finding the right balance between retention length, system performance, and cost.
For very large deployments or extremely long retention requirements, consider specialized solutions like Better Stack that build on Prometheus while addressing the challenges of long-term storage and querying massive time-series datasets.
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.