diff --git a/CHANGELOG.md b/CHANGELOG.md index 45a2c90e53..d082e98efc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#3346](https://github.com/thanos-io/thanos/pull/3346) Ruler UI: Fix a bug preventing the /rules endpoint from loading. - [#3115](https://github.com/thanos-io/thanos/pull/3115) compact: now deletes partially uploaded and blocks with deletion marks concurrently. It does that at the beginning and then every `--compact.cleanup-interval` time period. By default it is 5 minutes. - [#3312](https://github.com/thanos-io/thanos/pull/3312) s3: add list_objects_version config option for compatibility. +- [#3356](https://github.com/thanos-io/thanos/pull/3356) Query Frontend: Add a flag to disable step alignment middleware for query range. ### Fixed - [#3257](https://github.com/thanos-io/thanos/pull/3257) Ruler: Prevent Ruler from crashing when using default DNS to lookup hosts that results in "No such hosts" errors. diff --git a/cmd/thanos/query_frontend.go b/cmd/thanos/query_frontend.go index fe926b0abf..674ddd0c96 100644 --- a/cmd/thanos/query_frontend.go +++ b/cmd/thanos/query_frontend.go @@ -58,6 +58,9 @@ func registerQueryFrontend(app *extkingpin.App) { cfg.http.registerFlag(cmd) // Query range tripperware flags. + cmd.Flag("query-range.align-range-with-step", "Mutate incoming queries to align their start and end with their step for better cache-ability. Note: Grafana dashboards do that by default."). + Default("true").BoolVar(&cfg.QueryRangeConfig.AlignRangeWithStep) + cmd.Flag("query-range.split-interval", "Split query range requests by an interval and execute in parallel, it should be greater than 0 when query-range.response-cache-config is configured."). Default("24h").DurationVar(&cfg.QueryRangeConfig.SplitQueriesByInterval) diff --git a/docs/components/query-frontend.md b/docs/components/query-frontend.md index f8bd6d0a81..83451fcd03 100644 --- a/docs/components/query-frontend.md +++ b/docs/components/query-frontend.md @@ -126,6 +126,11 @@ Flags: Listen host:port for HTTP endpoints. --http-grace-period=2m Time to wait after an interrupt received for HTTP Server. + --query-range.align-range-with-step + Mutate incoming queries to align their start + and end with their step for better + cache-ability. Note: Grafana dashboards do that + by default. --query-range.split-interval=24h Split query range requests by an interval and execute in parallel, it should be greater than diff --git a/pkg/queryfrontend/config.go b/pkg/queryfrontend/config.go index 1f5cdd3264..6f0550b46d 100644 --- a/pkg/queryfrontend/config.go +++ b/pkg/queryfrontend/config.go @@ -139,6 +139,7 @@ type QueryRangeConfig struct { ResultsCacheConfig *queryrange.ResultsCacheConfig CachePathOrContent extflag.PathOrContent + AlignRangeWithStep bool SplitQueriesByInterval time.Duration MaxRetries int Limits *cortexvalidation.Limits diff --git a/pkg/queryfrontend/roundtrip.go b/pkg/queryfrontend/roundtrip.go index 5190ae8db3..e31ae98846 100644 --- a/pkg/queryfrontend/roundtrip.go +++ b/pkg/queryfrontend/roundtrip.go @@ -144,11 +144,13 @@ func newQueryRangeTripperware( m := queryrange.NewInstrumentMiddlewareMetrics(reg) // step align middleware. - queryRangeMiddleware = append( - queryRangeMiddleware, - queryrange.InstrumentMiddleware("step_align", m), - queryrange.StepAlignMiddleware, - ) + if config.AlignRangeWithStep { + queryRangeMiddleware = append( + queryRangeMiddleware, + queryrange.InstrumentMiddleware("step_align", m), + queryrange.StepAlignMiddleware, + ) + } queryIntervalFn := func(_ queryrange.Request) time.Duration { return config.SplitQueriesByInterval