From e0ea05665a5261d90af9591ced93c57380762a1d Mon Sep 17 00:00:00 2001 From: GeorgeTyupin <44722304+GeorgeTyupin@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:22:15 +0300 Subject: [PATCH] cmd/prometheus: add default values for agent min/max retention flags (#18261) * cmd/prometheus: add default values for agent min/max retention flags Signed-off-by: GeorgeTyupin * docs: update command-line flags documentation Signed-off-by: GeorgeTyupin * chore: trigger CI (retry 4) Signed-off-by: GeorgeTyupin * Reuse db.go constants for agent retention flags to avoid duplication. Signed-off-by: GeorgeTyupin --------- Signed-off-by: GeorgeTyupin --- cmd/prometheus/main.go | 8 ++++++-- docs/command-line/prometheus.md | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 5fd78a31f4..9b4ba0f4ba 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -541,13 +541,17 @@ func main() { "The frequency at which to truncate the WAL and remove old data."). Hidden().PlaceHolder("").SetValue(&cfg.agent.TruncateFrequency) + // Dynamically calculate the format strings from the tsdb/agent constants + agentDefaultMinWALTime := model.Duration(agent.DefaultMinWALTime * int64(time.Millisecond)).String() + agentDefaultMaxWALTime := model.Duration(agent.DefaultMaxWALTime * int64(time.Millisecond)).String() + agentOnlyFlag(a, "storage.agent.retention.min-time", "Minimum age samples may be before being considered for deletion when the WAL is truncated"). - SetValue(&cfg.agent.MinWALTime) + Default(agentDefaultMinWALTime).SetValue(&cfg.agent.MinWALTime) agentOnlyFlag(a, "storage.agent.retention.max-time", "Maximum age samples may be before being forcibly deleted when the WAL is truncated"). - SetValue(&cfg.agent.MaxWALTime) + Default(agentDefaultMaxWALTime).SetValue(&cfg.agent.MaxWALTime) agentOnlyFlag(a, "storage.agent.no-lockfile", "Do not create lockfile in data directory."). Default("false").BoolVar(&cfg.agent.NoLockfile) diff --git a/docs/command-line/prometheus.md b/docs/command-line/prometheus.md index 93cf7c63b9..ad4763d716 100644 --- a/docs/command-line/prometheus.md +++ b/docs/command-line/prometheus.md @@ -41,8 +41,8 @@ The Prometheus monitoring server | --storage.tsdb.delay-compact-file.path | Path to a JSON file with uploaded TSDB blocks e.g. Thanos shipper meta file. If set TSDB will only compact 1 level blocks that are marked as uploaded in that file, improving external storage integrations e.g. with Thanos sidecar. 1+ level compactions won't be delayed. Use with server mode only. | | | --storage.agent.path | Base path for metrics storage. Use with agent mode only. | `data-agent/` | | --storage.agent.wal-compression | Compress the agent WAL. If false, the --storage.agent.wal-compression-type flag is ignored. Use with agent mode only. | `true` | -| --storage.agent.retention.min-time | Minimum age samples may be before being considered for deletion when the WAL is truncated Use with agent mode only. | | -| --storage.agent.retention.max-time | Maximum age samples may be before being forcibly deleted when the WAL is truncated Use with agent mode only. | | +| --storage.agent.retention.min-time | Minimum age samples may be before being considered for deletion when the WAL is truncated Use with agent mode only. | `5m` | +| --storage.agent.retention.max-time | Maximum age samples may be before being forcibly deleted when the WAL is truncated Use with agent mode only. | `4h` | | --storage.agent.no-lockfile | Do not create lockfile in data directory. Use with agent mode only. | `false` | | --storage.remote.flush-deadline | How long to wait flushing sample on shutdown or config reload. | `1m` | | --storage.remote.read-sample-limit | Maximum overall number of samples to return via the remote read interface, in a single query. 0 means no limit. This limit is ignored for streamed response types. Use with server mode only. | `5e7` |