oijkn / Docker-Raspberry-PI-Monitoring

A docker-compose stack solution for monitoring host and containers with Prometheus, Grafana, cAdvisor and NodeExporter.
MIT License
363 stars 55 forks source link

Purge Prometheus database and reduce retention time #36

Closed Stoobiedoo closed 2 months ago

Stoobiedoo commented 3 months ago

I have this setup running on a normal Ubuntu server and the database has grown to several gigabytes in size.

How can I set the Prometheus database to only retain a certain time period of data and discard the rest? Is there a way to manually purge the database entries? I'm hesitant to just delete the files in the /Docker-Raspberry-PI-Monitoring/prometheus/data folder.

sierikov commented 2 months ago

I'm not an expert on Prometheus, so please correct me if I'm mistaken.

In the docker-compose.yml file, under the prometheus service, under the command section, you can add the following options to ensure that the data for the last 15 days is always kept (for example) under 10 GB:

- '--storage.tsdb.retention.time=15d' # Retains data for 15 days
- '--storage.tsdb.retention.size=10GB' # Limits data retention to 10GB

Afterward, you will need to restart or recreate the service for the changes to take effect.

Other options you can find in Storage Docs.

Stoobiedoo commented 2 months ago

That worked! Thanks for the answer.