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.
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.
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.
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.
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.
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.
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.
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.
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.
Let Dr. Droid create custom investigation plans for your infrastructure.
Start Free POC (15-min setup) →