diff --git a/opts.go b/opts.go index 2ab7044..54f1b7a 100644 --- a/opts.go +++ b/opts.go @@ -76,6 +76,10 @@ func init() { } for _, f := range parser.Functions { + // holt_winters is excluded by default; use WithEnableHoltWinters(true) for older backends. + if f.Name == "holt_winters" { + continue + } // Ignore experimental functions for now. if !f.Experimental { defaultSupportedFuncs = append(defaultSupportedFuncs, f) @@ -94,6 +98,7 @@ type options struct { enableOffset bool enableAtModifier bool enableVectorMatching bool + enableHoltWinters bool // holt_winters not in Prometheus 3.x; enable for older backends enableExperimentalPromQLFunctions bool atModifierMaxTimestamp int64 @@ -119,6 +124,10 @@ func (o *options) applyDefaults() { o.enabledFuncs = defaultSupportedFuncs } + if o.enableHoltWinters && parser.Functions["holt_winters"] != nil { + o.enabledFuncs = append(o.enabledFuncs, parser.Functions["holt_winters"]) + } + if o.enableExperimentalPromQLFunctions { o.enabledAggrs = append(o.enabledAggrs, experimentalPromQLAggrs...) o.enabledFuncs = append(o.enabledFuncs, experimentalSupportedFuncs...) @@ -168,6 +177,15 @@ func WithEnableVectorMatching(enableVectorMatching bool) Option { }) } +// WithEnableHoltWinters enables generation of holt_winters() in queries. +// Disabled by default because Prometheus 3.x replaced it with double_exponential_smoothing; +// enable only when fuzzing older backends that still support holt_winters. +func WithEnableHoltWinters(enable bool) Option { + return optionFunc(func(o *options) { + o.enableHoltWinters = enable + }) +} + func WithEnableExperimentalPromQLFunctions(enableExperimentalPromQLFunctions bool) Option { return optionFunc(func(o *options) { o.enableExperimentalPromQLFunctions = enableExperimentalPromQLFunctions