From 5834379fe30b1a21b9fb2d6d7de225f939370668 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 16 Oct 2024 18:33:44 +0000 Subject: [PATCH 1/8] Added Monitoring.Retention configuration parameter --- docs/parameters.yaml | 6 ++++++ param/parameters.go | 1 + param/parameters_struct.go | 2 ++ 3 files changed, 9 insertions(+) diff --git a/docs/parameters.yaml b/docs/parameters.yaml index 12bececec..7af4be7a8 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -2255,6 +2255,12 @@ type: bool default: true components: ["origin", "cache", "director", "registry"] --- +name: Monitoring.Retention +description: |+ + The duration of which Prometheus should retain the monitoring data. +type: string +default: "15d" +--- ############################ # Shoveler-level configs # ############################ diff --git a/param/parameters.go b/param/parameters.go index 3afc09f9d..5aa7e05cd 100644 --- a/param/parameters.go +++ b/param/parameters.go @@ -190,6 +190,7 @@ var ( Lotman_DbLocation = StringParam{"Lotman.DbLocation"} Lotman_LibLocation = StringParam{"Lotman.LibLocation"} Monitoring_DataLocation = StringParam{"Monitoring.DataLocation"} + Monitoring_Retention = StringParam{"Monitoring.Retention"} OIDC_AuthorizationEndpoint = StringParam{"OIDC.AuthorizationEndpoint"} OIDC_ClientID = StringParam{"OIDC.ClientID"} OIDC_ClientIDFile = StringParam{"OIDC.ClientIDFile"} diff --git a/param/parameters_struct.go b/param/parameters_struct.go index 32cc73682..08042b401 100644 --- a/param/parameters_struct.go +++ b/param/parameters_struct.go @@ -155,6 +155,7 @@ type Config struct { PortHigher int `mapstructure:"porthigher"` PortLower int `mapstructure:"portlower"` PromQLAuthorization bool `mapstructure:"promqlauthorization"` + Retention string `mapstructure:"retention"` TokenExpiresIn time.Duration `mapstructure:"tokenexpiresin"` TokenRefreshInterval time.Duration `mapstructure:"tokenrefreshinterval"` } `mapstructure:"monitoring"` @@ -451,6 +452,7 @@ type configWithType struct { PortHigher struct { Type string; Value int } PortLower struct { Type string; Value int } PromQLAuthorization struct { Type string; Value bool } + Retention struct { Type string; Value string } TokenExpiresIn struct { Type string; Value time.Duration } TokenRefreshInterval struct { Type string; Value time.Duration } } From 5a9151f5fba6ccbc201da62f25a920be297d60dc Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 21 Oct 2024 18:13:27 +0000 Subject: [PATCH 2/8] Added default retention time --- config/resources/defaults.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/resources/defaults.yaml b/config/resources/defaults.yaml index dad7b706e..42433fa92 100644 --- a/config/resources/defaults.yaml +++ b/config/resources/defaults.yaml @@ -88,6 +88,7 @@ Monitoring: MetricAuthorization: true PromQLAuthorization: true AggregatePrefixes: ["/*"] + Retention: 15d Shoveler: MessageQueueProtocol: amqp PortLower: 9930 From 570eea7ebab4f71b17089238e36dd50a735118fb Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 21 Oct 2024 18:19:53 +0000 Subject: [PATCH 3/8] Move retention parsing outside of init() function --- web_ui/prometheus.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/web_ui/prometheus.go b/web_ui/prometheus.go index 6341a1020..322498f9a 100644 --- a/web_ui/prometheus.go +++ b/web_ui/prometheus.go @@ -74,9 +74,6 @@ import ( var ( appName = "prometheus" - defaultRetentionString = "15d" - defaultRetentionDuration model.Duration - globalConfig config.Config globalConfigMtx sync.RWMutex @@ -85,12 +82,6 @@ var ( func init() { prometheus.MustRegister(version.NewCollector(strings.ReplaceAll(appName, "-", "_"))) - - var err error - defaultRetentionDuration, err = model.ParseDuration(defaultRetentionString) - if err != nil { - panic(err) - } } type flagConfig struct { @@ -422,7 +413,12 @@ func ConfigureEmbeddedPrometheus(ctx context.Context, engine *gin.Engine) error cfg.tsdb.OutOfOrderTimeWindow = promCfg.StorageConfig.TSDBConfig.OutOfOrderTimeWindow } - cfg.tsdb.RetentionDuration = defaultRetentionDuration + retention, err := model.ParseDuration(param.Monitoring_Retention.GetString()) + if err != nil { + // If we are here, it means that the duration that was set in the config is invalid + return fmt.Errorf("failed to parse retention duration: %v", err) + } + cfg.tsdb.RetentionDuration = retention // Max block size settings. if cfg.tsdb.MaxBlockDuration == 0 { From 2931ad12896e725abf799e2d1c23aab3672f2d10 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 21 Oct 2024 18:31:01 +0000 Subject: [PATCH 4/8] Add components to parameter.yaml --- docs/parameters.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/parameters.yaml b/docs/parameters.yaml index 7af4be7a8..2eccb29fe 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -2260,6 +2260,7 @@ description: |+ The duration of which Prometheus should retain the monitoring data. type: string default: "15d" +components: ["origin", "cache", "director", "registry"] --- ############################ # Shoveler-level configs # From 647d87f35ce2018f74bb16a969f15d9473f4555d Mon Sep 17 00:00:00 2001 From: Patrick Brophy Date: Mon, 21 Oct 2024 15:41:57 -0400 Subject: [PATCH 5/8] Change parameter type to duration Co-authored-by: Cannon Lock <49032265+CannonLock@users.noreply.github.com> --- docs/parameters.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/parameters.yaml b/docs/parameters.yaml index 2eccb29fe..fc3d3665a 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -2258,7 +2258,7 @@ components: ["origin", "cache", "director", "registry"] name: Monitoring.Retention description: |+ The duration of which Prometheus should retain the monitoring data. -type: string +type: duration default: "15d" components: ["origin", "cache", "director", "registry"] --- From 2d88aff63403c1d94486f85ef2b13e540d1a977d Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 21 Oct 2024 19:44:06 +0000 Subject: [PATCH 6/8] Update parameters structures --- param/parameters.go | 2 +- param/parameters_struct.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/param/parameters.go b/param/parameters.go index 5aa7e05cd..d0b75ae41 100644 --- a/param/parameters.go +++ b/param/parameters.go @@ -190,7 +190,6 @@ var ( Lotman_DbLocation = StringParam{"Lotman.DbLocation"} Lotman_LibLocation = StringParam{"Lotman.LibLocation"} Monitoring_DataLocation = StringParam{"Monitoring.DataLocation"} - Monitoring_Retention = StringParam{"Monitoring.Retention"} OIDC_AuthorizationEndpoint = StringParam{"OIDC.AuthorizationEndpoint"} OIDC_ClientID = StringParam{"OIDC.ClientID"} OIDC_ClientIDFile = StringParam{"OIDC.ClientIDFile"} @@ -377,6 +376,7 @@ var ( Director_OriginCacheHealthTestInterval = DurationParam{"Director.OriginCacheHealthTestInterval"} Director_StatTimeout = DurationParam{"Director.StatTimeout"} Federation_TopologyReloadInterval = DurationParam{"Federation.TopologyReloadInterval"} + Monitoring_Retention = DurationParam{"Monitoring.Retention"} Monitoring_TokenExpiresIn = DurationParam{"Monitoring.TokenExpiresIn"} Monitoring_TokenRefreshInterval = DurationParam{"Monitoring.TokenRefreshInterval"} Origin_SelfTestInterval = DurationParam{"Origin.SelfTestInterval"} diff --git a/param/parameters_struct.go b/param/parameters_struct.go index 08042b401..87a737bb6 100644 --- a/param/parameters_struct.go +++ b/param/parameters_struct.go @@ -155,7 +155,7 @@ type Config struct { PortHigher int `mapstructure:"porthigher"` PortLower int `mapstructure:"portlower"` PromQLAuthorization bool `mapstructure:"promqlauthorization"` - Retention string `mapstructure:"retention"` + Retention time.Duration `mapstructure:"retention"` TokenExpiresIn time.Duration `mapstructure:"tokenexpiresin"` TokenRefreshInterval time.Duration `mapstructure:"tokenrefreshinterval"` } `mapstructure:"monitoring"` @@ -452,7 +452,7 @@ type configWithType struct { PortHigher struct { Type string; Value int } PortLower struct { Type string; Value int } PromQLAuthorization struct { Type string; Value bool } - Retention struct { Type string; Value string } + Retention struct { Type string; Value time.Duration } TokenExpiresIn struct { Type string; Value time.Duration } TokenRefreshInterval struct { Type string; Value time.Duration } } From c584c46956012eed93466ef46283c420a46f996d Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 21 Oct 2024 19:55:07 +0000 Subject: [PATCH 7/8] Updated defaults and updated setting retention logic --- config/resources/defaults.yaml | 2 +- docs/parameters.yaml | 2 +- web_ui/prometheus.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/resources/defaults.yaml b/config/resources/defaults.yaml index 42433fa92..6c74dd713 100644 --- a/config/resources/defaults.yaml +++ b/config/resources/defaults.yaml @@ -88,7 +88,7 @@ Monitoring: MetricAuthorization: true PromQLAuthorization: true AggregatePrefixes: ["/*"] - Retention: 15d + Retention: 360h Shoveler: MessageQueueProtocol: amqp PortLower: 9930 diff --git a/docs/parameters.yaml b/docs/parameters.yaml index fc3d3665a..60e7261e6 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -2259,7 +2259,7 @@ name: Monitoring.Retention description: |+ The duration of which Prometheus should retain the monitoring data. type: duration -default: "15d" +default: 360h components: ["origin", "cache", "director", "registry"] --- ############################ diff --git a/web_ui/prometheus.go b/web_ui/prometheus.go index 322498f9a..e0b0035d2 100644 --- a/web_ui/prometheus.go +++ b/web_ui/prometheus.go @@ -413,7 +413,7 @@ func ConfigureEmbeddedPrometheus(ctx context.Context, engine *gin.Engine) error cfg.tsdb.OutOfOrderTimeWindow = promCfg.StorageConfig.TSDBConfig.OutOfOrderTimeWindow } - retention, err := model.ParseDuration(param.Monitoring_Retention.GetString()) + retention, err := model.ParseDuration(param.Monitoring_Retention.GetDuration().String()) if err != nil { // If we are here, it means that the duration that was set in the config is invalid return fmt.Errorf("failed to parse retention duration: %v", err) From 7ee3824baed7746dcf786d365839834b80b89e83 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 23 Oct 2024 18:27:36 +0000 Subject: [PATCH 8/8] Rename Monitoring.Retention to Monitoring.DataRetention --- config/resources/defaults.yaml | 2 +- docs/parameters.yaml | 2 +- param/parameters.go | 2 +- param/parameters_struct.go | 4 ++-- web_ui/prometheus.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/resources/defaults.yaml b/config/resources/defaults.yaml index 6c74dd713..d513456c1 100644 --- a/config/resources/defaults.yaml +++ b/config/resources/defaults.yaml @@ -88,7 +88,7 @@ Monitoring: MetricAuthorization: true PromQLAuthorization: true AggregatePrefixes: ["/*"] - Retention: 360h + DataRetention: 360h Shoveler: MessageQueueProtocol: amqp PortLower: 9930 diff --git a/docs/parameters.yaml b/docs/parameters.yaml index 60e7261e6..5e75ace04 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -2255,7 +2255,7 @@ type: bool default: true components: ["origin", "cache", "director", "registry"] --- -name: Monitoring.Retention +name: Monitoring.DataRetention description: |+ The duration of which Prometheus should retain the monitoring data. type: duration diff --git a/param/parameters.go b/param/parameters.go index d0b75ae41..5c9d5534d 100644 --- a/param/parameters.go +++ b/param/parameters.go @@ -376,7 +376,7 @@ var ( Director_OriginCacheHealthTestInterval = DurationParam{"Director.OriginCacheHealthTestInterval"} Director_StatTimeout = DurationParam{"Director.StatTimeout"} Federation_TopologyReloadInterval = DurationParam{"Federation.TopologyReloadInterval"} - Monitoring_Retention = DurationParam{"Monitoring.Retention"} + Monitoring_DataRetention = DurationParam{"Monitoring.DataRetention"} Monitoring_TokenExpiresIn = DurationParam{"Monitoring.TokenExpiresIn"} Monitoring_TokenRefreshInterval = DurationParam{"Monitoring.TokenRefreshInterval"} Origin_SelfTestInterval = DurationParam{"Origin.SelfTestInterval"} diff --git a/param/parameters_struct.go b/param/parameters_struct.go index 87a737bb6..49daa3293 100644 --- a/param/parameters_struct.go +++ b/param/parameters_struct.go @@ -151,11 +151,11 @@ type Config struct { Monitoring struct { AggregatePrefixes []string `mapstructure:"aggregateprefixes"` DataLocation string `mapstructure:"datalocation"` + DataRetention time.Duration `mapstructure:"dataretention"` MetricAuthorization bool `mapstructure:"metricauthorization"` PortHigher int `mapstructure:"porthigher"` PortLower int `mapstructure:"portlower"` PromQLAuthorization bool `mapstructure:"promqlauthorization"` - Retention time.Duration `mapstructure:"retention"` TokenExpiresIn time.Duration `mapstructure:"tokenexpiresin"` TokenRefreshInterval time.Duration `mapstructure:"tokenrefreshinterval"` } `mapstructure:"monitoring"` @@ -448,11 +448,11 @@ type configWithType struct { Monitoring struct { AggregatePrefixes struct { Type string; Value []string } DataLocation struct { Type string; Value string } + DataRetention struct { Type string; Value time.Duration } MetricAuthorization struct { Type string; Value bool } PortHigher struct { Type string; Value int } PortLower struct { Type string; Value int } PromQLAuthorization struct { Type string; Value bool } - Retention struct { Type string; Value time.Duration } TokenExpiresIn struct { Type string; Value time.Duration } TokenRefreshInterval struct { Type string; Value time.Duration } } diff --git a/web_ui/prometheus.go b/web_ui/prometheus.go index e0b0035d2..ac936870a 100644 --- a/web_ui/prometheus.go +++ b/web_ui/prometheus.go @@ -413,7 +413,7 @@ func ConfigureEmbeddedPrometheus(ctx context.Context, engine *gin.Engine) error cfg.tsdb.OutOfOrderTimeWindow = promCfg.StorageConfig.TSDBConfig.OutOfOrderTimeWindow } - retention, err := model.ParseDuration(param.Monitoring_Retention.GetDuration().String()) + retention, err := model.ParseDuration(param.Monitoring_DataRetention.GetDuration().String()) if err != nil { // If we are here, it means that the duration that was set in the config is invalid return fmt.Errorf("failed to parse retention duration: %v", err)