Skip to content

Commit

Permalink
Merge pull request PelicanPlatform#1670 from patrickbrophy/fix-issue-…
Browse files Browse the repository at this point in the history
…1640

Configurable Prometheus Retention
  • Loading branch information
jhiemstrawisc authored Oct 25, 2024
2 parents ff5ff14 + 7ee3824 commit b0bbed2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions config/resources/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Monitoring:
MetricAuthorization: true
PromQLAuthorization: true
AggregatePrefixes: ["/*"]
DataRetention: 360h
Shoveler:
MessageQueueProtocol: amqp
PortLower: 9930
Expand Down
7 changes: 7 additions & 0 deletions docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
############################
Expand Down
1 change: 1 addition & 0 deletions param/parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions param/parameters_struct.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions web_ui/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ import (
var (
appName = "prometheus"

defaultRetentionString = "15d"
defaultRetentionDuration model.Duration

globalConfig config.Config
globalConfigMtx sync.RWMutex

Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b0bbed2

Please sign in to comment.