Skip to content

Commit

Permalink
add logic
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <yb532204897@gmail.com>
  • Loading branch information
yeya24 committed Oct 26, 2020
1 parent ad540e2 commit 1adae87
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmd/thanos/query_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func registerQueryFrontend(app *extkingpin.App) {
cfg.http.registerFlag(cmd)

// Query range tripperware flags.
cmd.Flag("query-range.align-querier-with-step", "Mutate incoming queries to align their start and end with their step.").
Default("true").BoolVar(&cfg.QueryRangeConfig.AlignQueriesWithStep)
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)
Expand Down
6 changes: 4 additions & 2 deletions docs/components/query-frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +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-querier-with-step
--query-range.align-range-with-step
Mutate incoming queries to align their start
and end with their step.
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
Expand Down
2 changes: 1 addition & 1 deletion pkg/queryfrontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type QueryRangeConfig struct {
ResultsCacheConfig *queryrange.ResultsCacheConfig
CachePathOrContent extflag.PathOrContent

AlignQueriesWithStep bool
AlignRangeWithStep bool
SplitQueriesByInterval time.Duration
MaxRetries int
Limits *cortexvalidation.Limits
Expand Down
12 changes: 7 additions & 5 deletions pkg/queryfrontend/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1adae87

Please sign in to comment.