-
Notifications
You must be signed in to change notification settings - Fork 615
Monitoring API: remove maximum retention days prometheus #2851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a821031
0486146
13d2859
86b8e12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1340,7 +1340,7 @@ type PrometheusConfig struct { | |
| // +kubebuilder:validation:MinItems=1 | ||
| Resources []ContainerResource `json:"resources,omitempty"` | ||
| // retention configures how long Prometheus retains metrics data and how much storage it can use. | ||
| // When omitted, the platform chooses reasonable defaults (currently 15 days retention, no size limit). | ||
| // When omitted, the platform chooses reasonable defaults (currently 15d retention, no size limit). | ||
| // +optional | ||
| Retention Retention `json:"retention,omitempty,omitzero"` | ||
| // tolerations defines tolerations for the pods. | ||
|
|
@@ -2234,8 +2234,11 @@ type SecretKeySelector struct { | |
|
|
||
| // Retention configures how long Prometheus retains metrics data and how much storage it can use. | ||
| // +kubebuilder:validation:MinProperties=1 | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.durationInDays) || !has(self.duration)",message="durationInDays and duration cannot both be set" | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.sizeInGiB) || !has(self.size)",message="sizeInGiB and size cannot both be set" | ||
| type Retention struct { | ||
| // durationInDays specifies how many days Prometheus will retain metrics data. | ||
| // Deprecated: use duration instead. durationInDays and duration cannot both be set. | ||
| // Prometheus automatically deletes data older than this duration. | ||
| // When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time. | ||
| // The default value is 15. | ||
|
|
@@ -2245,8 +2248,10 @@ type Retention struct { | |
| // +kubebuilder:validation:Maximum=365 | ||
| // +optional | ||
| DurationInDays int32 `json:"durationInDays,omitempty"` | ||
|
|
||
| // sizeInGiB specifies the maximum storage size in gibibytes (GiB) that Prometheus | ||
| // can use for data blocks and the write-ahead log (WAL). | ||
| // Deprecated: use size instead. sizeInGiB and size cannot both be set. | ||
| // When the limit is reached, Prometheus will delete oldest data first. | ||
| // When omitted, no size limit is enforced and Prometheus uses available PersistentVolume capacity. | ||
| // Minimum value is 1 GiB. | ||
|
|
@@ -2255,6 +2260,39 @@ type Retention struct { | |
| // +kubebuilder:validation:Maximum=16384 | ||
| // +optional | ||
| SizeInGiB int32 `json:"sizeInGiB,omitempty"` | ||
|
|
||
| // duration is an optional field that specifies how long Prometheus retains metrics data. | ||
| // Valid values are Prometheus duration strings composed of non-negative integer components | ||
| // with unit suffixes y, w, d, h, m, s, or ms (for example, "15d", "24h", "15h"). | ||
| // Single-unit forms such as "15d" or "24h" are recommended over composite durations with | ||
| // zero-valued components (for example, "0y5d"), which are redundant but valid upstream. | ||
| // Must be at least 1 character and at most 64 characters. | ||
| // When set to "0", time-based retention is disabled. Other zero-duration forms such as "0d", | ||
| // "0h", or "0y" are semantically equivalent in Prometheus parsing, but "0" is the canonical | ||
| // documented form for disabling time-based retention. | ||
| // Prometheus automatically deletes data older than this duration. | ||
| // When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time. | ||
| // The current default value is `15d`. | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=64 | ||
| // +kubebuilder:validation:XValidation:rule=`self.matches('^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$')`,message="must be a valid Prometheus duration string" | ||
| // +optional | ||
| Duration string `json:"duration,omitempty"` | ||
|
|
||
| // size is an optional field that specifies the maximum storage size that Prometheus | ||
| // can use for data blocks and the write-ahead log (WAL). | ||
| // Valid values are Prometheus byte-size strings with an optional decimal prefix and a | ||
| // unit suffix B, KB, MB, GB, TB, EB, PB, or their binary equivalents KiB, MiB, GiB, TiB, EiB, PiB | ||
| // (for example, "500MiB", "10GiB"). | ||
| // Must be at least 1 character and at most 32 characters. | ||
| // When set to "0", no size limit is enforced. | ||
| // When the limit is reached, Prometheus deletes oldest data first. | ||
| // When omitted, no size limit is enforced and Prometheus uses available PersistentVolume capacity. | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=32 | ||
| // +kubebuilder:validation:XValidation:rule=`self.matches('^(0|([0-9]*[.])?[0-9]+((K|M|G|T|E|P)i?)?B)$')`,message="must be a valid Prometheus byte-size string" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar question here, if you aren't setting this to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prometheus Operator’s ByteSize pattern admits 500B ,the scale part is optional, you just need the trailing B. I copied that on purpose so retention.size can go straight through to retentionSize on the Prometheus CR without conversion. |
||
| // +optional | ||
| Size string `json:"size,omitempty"` | ||
| } | ||
|
|
||
| // RelabelAction defines the action to perform in a relabeling rule. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is setting this field to
0any different than setting it to0yor0d?Should we require that if you are not disabling retention all of your units must specify a value greater than 0?
For example,
0y10m5d1h30mdoesn't really make sense to have the0yto me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"0","0d", and"0y"are semantically equivalent (zero duration) in Prometheus parsing. We intentionally use the same validation pattern as the Prometheus Operatorretentionfield so CMO can pass values through unchanged.Upstream does not reject zero-valued components like
0yin composite durations, so we are not adding stricter admission rules here. We document"0"as the canonical way to disable time-based retention and recommend single-unit forms like"15d"or"24h"in field comments, but validation matches upstream.Note: composite durations must follow the fixed unit order (
y→w→d→h→m→s→ms), so values like0y10m5dare invalid; valid examples with zero components include0y5d1h30mor0d15h.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"0", "0d", and "0y" are semantically equivalent (zero duration) in Prometheus parsing. I intentionally use the same validation pattern as the Prometheus Operator retention field so CMO can pass values through unchanged.
I can add a comment if it is neccesary