Thanos Retention policies are not being applied in Thanos compaction.

Misconfiguration of retention policy settings.

Understanding Thanos and Its Purpose

Thanos is an open-source project that provides highly available Prometheus setup with long-term storage capabilities. It is designed to aggregate data from multiple Prometheus instances and store it in a highly available and scalable manner. Thanos extends Prometheus by adding components like Sidecar, Store, Compactor, and Querier, which help in achieving global query view, downsampling, and data retention.

Identifying the Symptom: Retention Policy Not Applied

One common issue encountered by Thanos users is that the retention policies are not being applied as expected. This can manifest as older data not being deleted according to the configured retention settings, leading to increased storage usage and potential performance degradation.

Exploring the Issue: Misconfiguration of Retention Policies

The root cause of this issue often lies in the misconfiguration of retention policy settings within the Thanos compactor. The compactor is responsible for applying retention policies and downsampling data. If the settings are incorrect, the compactor may not delete old data as intended.

Common Misconfigurations

  • Incorrect retention period specified in the configuration.
  • Compactor not running or improperly scheduled.
  • Misconfigured flags or environment variables.

Steps to Fix the Retention Policy Issue

To resolve the issue of retention policies not being applied, follow these steps:

Step 1: Verify Compactor Configuration

Ensure that the compactor is correctly configured with the desired retention period. Check the configuration file or command-line flags used to start the compactor. The --retention.resolution-raw, --retention.resolution-5m, and --retention.resolution-1h flags should be set according to your retention needs.

thanos compact \
--data-dir /var/thanos/compact \
--retention.resolution-raw=30d \
--retention.resolution-5m=90d \
--retention.resolution-1h=1y

Step 2: Check Compactor Logs

Review the logs of the Thanos compactor to identify any errors or warnings that might indicate why the retention policies are not being applied. Logs can provide insights into misconfigurations or operational issues.

Step 3: Ensure Compactor is Running

Verify that the compactor is running and scheduled correctly. If using Kubernetes, ensure that the compactor pod is running and not in a crash loop. You can check the status with:

kubectl get pods -n -l app=thanos-compactor

Step 4: Validate Configuration Files

Double-check the configuration files for any syntax errors or incorrect settings. Ensure that the YAML or JSON configuration files are correctly formatted and that all necessary parameters are specified.

Additional Resources

For more information on configuring Thanos and troubleshooting common issues, refer to the following resources:

By following these steps and verifying your configuration, you should be able to resolve the issue of retention policies not being applied in Thanos.

Master

Thanos

in Minutes — Grab the Ultimate Cheatsheet

(Perfect for DevOps & SREs)

Most-used commands
Real-world configs/examples
Handy troubleshooting shortcuts
Your email is safe with us. No spam, ever.

Thankyou for your submission

We have sent the whitepaper on your email!
Oops! Something went wrong while submitting the form.

Thanos

Cheatsheet

(Perfect for DevOps & SREs)

Most-used commands
Your email is safe with us. No spam, ever.

Thankyou for your submission

We have sent the whitepaper on your email!
Oops! Something went wrong while submitting the form.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid