Prometheus Prometheus not retaining data

Retention settings too low or storage issues.

Understanding Prometheus and Its Purpose

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. It is now a standalone open source project and maintained independently of any company. Prometheus collects and stores its metrics as time series data, i.e., metrics information is stored with the timestamp at which it was recorded, alongside optional key-value pairs called labels.

For more detailed information about Prometheus, you can visit the official Prometheus website.

Identifying the Symptom: Prometheus Not Retaining Data

One common issue users might encounter with Prometheus is that it does not retain data as expected. This symptom is observed when historical data is missing or when querying older data returns no results. This can be particularly problematic for long-term trend analysis and reporting.

Exploring the Issue: Retention Settings and Storage

Retention Settings

Prometheus uses a time-based retention policy to manage the amount of data stored. By default, Prometheus retains data for 15 days. If your retention settings are too low, Prometheus will automatically delete older data to free up space.

Storage Issues

Another potential cause for data not being retained is insufficient storage space. Prometheus requires adequate disk space to store its time series data. If the storage is full or nearly full, Prometheus may not be able to retain data as expected.

Steps to Fix the Issue

Step 1: Check Current Retention Settings

First, verify your current retention settings. You can do this by checking the Prometheus configuration file (usually named prometheus.yml). Look for the --storage.tsdb.retention.time flag, which specifies the retention duration.

--storage.tsdb.retention.time=30d

If this flag is not set, Prometheus defaults to a 15-day retention period.

Step 2: Increase Retention Settings

To increase the retention period, modify the prometheus.yml configuration file to include a longer retention time. For example, to retain data for 30 days, set:

--storage.tsdb.retention.time=30d

After making changes, restart the Prometheus server to apply the new settings.

Step 3: Verify Storage Availability

Ensure that there is sufficient disk space available for Prometheus to store data. You can check disk usage with the df -h command on Linux systems:

df -h

If the disk is full, consider expanding your storage or cleaning up unnecessary files.

Step 4: Monitor and Adjust

After making these changes, monitor your Prometheus instance to ensure data is being retained as expected. You can use Prometheus itself to monitor disk usage and retention metrics. Adjust retention settings and storage as necessary based on your monitoring results.

Conclusion

By understanding and adjusting retention settings and ensuring adequate storage, you can resolve issues related to Prometheus not retaining data. For further reading, check out the Prometheus Storage Documentation.

Never debug

Prometheus

manually again

Let Dr. Droid create custom investigation plans for your infrastructure.

Start Free POC (15-min setup) →
Automate Debugging for
Prometheus
See how Dr. Droid creates investigation plans for your infrastructure.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid