diff --git a/config/resources/defaults.yaml b/config/resources/defaults.yaml index 62853239e..2b233ca89 100644 --- a/config/resources/defaults.yaml +++ b/config/resources/defaults.yaml @@ -92,6 +92,7 @@ Monitoring: MetricAuthorization: true PromQLAuthorization: true AggregatePrefixes: ["/*"] + DataRetention: 360h Shoveler: MessageQueueProtocol: amqp PortLower: 9930 diff --git a/docs/parameters.yaml b/docs/parameters.yaml index 6911c82c2..abbac6268 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -2331,6 +2331,13 @@ type: bool default: true components: ["origin", "cache", "director", "registry"] --- +name: Monitoring.DataRetention +description: |+ + The duration of which Prometheus should retain the monitoring data. +type: duration +default: 360h +components: ["origin", "cache", "director", "registry"] +--- ############################ # Shoveler-level configs # ############################ diff --git a/param/parameters.go b/param/parameters.go index 1af215d7a..f00cb0909 100644 --- a/param/parameters.go +++ b/param/parameters.go @@ -385,6 +385,7 @@ var ( Director_OriginCacheHealthTestInterval = DurationParam{"Director.OriginCacheHealthTestInterval"} Director_StatTimeout = DurationParam{"Director.StatTimeout"} Federation_TopologyReloadInterval = DurationParam{"Federation.TopologyReloadInterval"} + 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 318566bf8..1e39835a2 100644 --- a/param/parameters_struct.go +++ b/param/parameters_struct.go @@ -156,6 +156,7 @@ 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"` @@ -457,6 +458,7 @@ 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 } diff --git a/web_ui/prometheus.go b/web_ui/prometheus.go index 337835ad6..72f4d07d3 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_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) + } + cfg.tsdb.RetentionDuration = retention // Max block size settings. if cfg.tsdb.MaxBlockDuration == 0 {