Skip to content

Conversation

@AstroProfundis
Copy link
Contributor

What problem does this PR solve?

Add support of retention by size for Prometheus. Default value is empty to keep former behavior unchanged. The storage.tsdb.retention.size and storage.tsdb.retention.time can be set together.

If both time and size retention policies are specified, whichever triggers first will be used.

See Prometheus doc for details.

Also close #2058

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    • Tested with TiDB v8.5.2, which uses Prometheus v2.49.1
  • No code

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release notes:

NONE

@ti-chi-bot ti-chi-bot bot requested a review from nexustar October 10, 2025 08:24
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Oct 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xhebox for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added contribution size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 10, 2025
AdditionalArgs: spec.AdditionalArgs,
}
// Set retention policy
if spec.RetentionTime == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to handle the deprecated Retention, right? Maybe add a comment about this. Could also be a good place to emit a warning about the use of deprecated things.

func getRetention(retention string) string {
func getRetentionSize(retention string) string {
retention = strings.ToUpper(strings.TrimSpace(retention))
valid, _ := regexp.MatchString("^[1-9]\\d*(B|KB|MB|GB|TB|PB|EB)$", retention)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about KiB etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see that in Prometheus doc though...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this should be fine.

retention = strings.ToUpper(strings.TrimSpace(retention))
valid, _ := regexp.MatchString("^[1-9]\\d*(B|KB|MB|GB|TB|PB|EB)$", retention)
if retention == "" || !valid {
return ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we log a warning or something similar if !valid ?

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Oct 31, 2025

@dveeden: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use storage.tsdb.retention.time instead of storage.tsdb.retention(DEPRECATED)

2 participants