diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 705a5cb0fb..5fd78a31f4 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -305,8 +305,6 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error { case "promql-binop-fill-modifiers": c.parserOpts.EnableBinopFillModifiers = true logger.Info("Experimental PromQL binary operator fill modifiers enabled.") - case "": - continue case "old-ui": c.web.UseOldUI = true logger.Info("Serving previous version of the Prometheus web UI.") @@ -608,8 +606,8 @@ func main() { a.Flag("scrape.discovery-reload-interval", "Interval used by scrape manager to throttle target groups updates."). Hidden().Default("5s").SetValue(&cfg.scrape.DiscoveryReloadInterval) - a.Flag("enable-feature", "Comma separated feature names to enable. Valid options: exemplar-storage, expand-external-labels, memory-snapshot-on-shutdown, promql-per-step-stats, promql-experimental-functions, extra-scrape-metrics, auto-gomaxprocs, created-timestamp-zero-ingestion, st-storage, concurrent-rule-eval, delayed-compaction, old-ui, otlp-deltatocumulative, promql-duration-expr, use-uncached-io, promql-extended-range-selectors, promql-binop-fill-modifiers, xor2-encoding. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details."). - Default("").StringsVar(&cfg.featureList) + a.Flag("enable-feature", "Comma separated feature names to enable. Valid options: auto-reload-config, concurrent-rule-eval, created-timestamp-zero-ingestion, delayed-compaction, exemplar-storage, extra-scrape-metrics, memory-snapshot-on-shutdown, metadata-wal-records, old-ui, otlp-deltatocumulative, otlp-native-delta-ingestion, promql-binop-fill-modifiers, promql-delayed-name-removal, promql-duration-expr, promql-experimental-functions, promql-extended-range-selectors, promql-per-step-stats, st-storage, type-and-unit-labels, use-uncached-io, xor2-encoding. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details."). + StringsVar(&cfg.featureList) a.Flag("agent", "Run Prometheus in 'Agent mode'.").BoolVar(&agentMode) diff --git a/cmd/prometheus/main_test.go b/cmd/prometheus/main_test.go index 0a37c9089d..5e57dd9352 100644 --- a/cmd/prometheus/main_test.go +++ b/cmd/prometheus/main_test.go @@ -26,6 +26,7 @@ import ( "os/exec" "path/filepath" "runtime" + "slices" "strconv" "strings" "sync" @@ -34,6 +35,7 @@ import ( "time" "github.com/alecthomas/kingpin/v2" + "github.com/grafana/regexp" remoteapi "github.com/prometheus/client_golang/exp/api/remote" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/expfmt" @@ -1062,3 +1064,30 @@ remote_write: // 3*shardUpdateDuration to allow for the resharding logic to run. }, 30*time.Second, time.Second) } + +// TestFeatureFlagsDocumented ensures the --enable-feature help text in main.go +// and the documented flags in docs/feature_flags.md list the same set of flags. +func TestFeatureFlagsDocumented(t *testing.T) { + if runtime.GOOS == "windows" { + t.SkipNow() + } + h, err := os.ReadFile(filepath.Join("..", "..", "cmd", "prometheus", "main.go")) + require.NoError(t, err) + m := regexp.MustCompile(`a\.Flag\("enable-feature", "Comma separated feature names to enable. Valid options: (.+?)\.`).FindSubmatch(h) + require.NotNil(t, m) + var helpFlags []string + for f := range strings.SplitSeq(string(m[1]), ",") { + helpFlags = append(helpFlags, strings.TrimSpace(f)) + } + require.NotEmpty(t, helpFlags) + + d, err := os.ReadFile(filepath.Join("..", "..", "docs", "feature_flags.md")) + require.NoError(t, err) + var docFlags []string + for _, dm := range regexp.MustCompile("(?m)^`--enable-feature=(.+)`$").FindAllSubmatch(d, -1) { + docFlags = append(docFlags, string(dm[1])) + } + require.NotEmpty(t, docFlags) + require.True(t, slices.IsSorted(helpFlags)) + require.ElementsMatch(t, helpFlags, docFlags) +} diff --git a/docs/command-line/prometheus.md b/docs/command-line/prometheus.md index 1c2a08c39c..93cf7c63b9 100644 --- a/docs/command-line/prometheus.md +++ b/docs/command-line/prometheus.md @@ -59,7 +59,7 @@ The Prometheus monitoring server | --query.timeout | Maximum time a query may take before being aborted. Use with server mode only. | `2m` | | --query.max-concurrency | Maximum number of queries executed concurrently. Use with server mode only. | `20` | | --query.max-samples | Maximum number of samples a single query can load into memory. Note that queries will fail if they try to load more samples than this into memory, so this also limits the number of samples a query can return. Use with server mode only. | `50000000` | -| --enable-feature ... | Comma separated feature names to enable. Valid options: exemplar-storage, expand-external-labels, memory-snapshot-on-shutdown, promql-per-step-stats, promql-experimental-functions, extra-scrape-metrics, auto-gomaxprocs, created-timestamp-zero-ingestion, st-storage, concurrent-rule-eval, delayed-compaction, old-ui, otlp-deltatocumulative, promql-duration-expr, use-uncached-io, promql-extended-range-selectors, promql-binop-fill-modifiers, xor2-encoding. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details. | | +| --enable-feature ... | Comma separated feature names to enable. Valid options: auto-reload-config, concurrent-rule-eval, created-timestamp-zero-ingestion, delayed-compaction, exemplar-storage, extra-scrape-metrics, memory-snapshot-on-shutdown, metadata-wal-records, old-ui, otlp-deltatocumulative, otlp-native-delta-ingestion, promql-binop-fill-modifiers, promql-delayed-name-removal, promql-duration-expr, promql-experimental-functions, promql-extended-range-selectors, promql-per-step-stats, st-storage, type-and-unit-labels, use-uncached-io, xor2-encoding. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details. | | | --agent | Run Prometheus in 'Agent mode'. | | | --log.level | Only log messages with the given severity or above. One of: [debug, info, warn, error] | `info` | | --log.format | Output format of log messages. One of: [logfmt, json] | `logfmt` |