Skip to content

Commit

Permalink
update flags and changelog
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 committed Oct 12, 2020
1 parent c57aa63 commit 35380a9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
## Unreleased

- [#3261](https://github.com/thanos-io/thanos/pull/3261) Thanos Store: Use segment files specified in meta.json file, if present. If not present, Store does the LIST operation as before.
- [#3276](https://github.com/thanos-io/thanos/pull/3276) Query Frontend: Support query splitting and retry for labels and series requests.

## [v0.16.0](https://github.com/thanos-io/thanos/releases) - Release in progress

Expand Down
27 changes: 17 additions & 10 deletions cmd/thanos/query_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,46 @@ func registerQueryFrontend(app *extkingpin.App) {

cfg.http.registerFlag(cmd)

// Query range tripperware flags.
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)
cmd.Flag("labels.split-interval", "Split labels requests by an interval and execute in parallel, it should be greater than 0 when labels.response-cache-config is configured.").
Default("24h").DurationVar(&cfg.LabelsConfig.SplitQueriesByInterval)

cmd.Flag("query-range.max-retries-per-request", "Maximum number of retries for a single query range request; beyond this, the downstream error is returned.").
Default("5").IntVar(&cfg.QueryRangeConfig.MaxRetries)
cmd.Flag("labels.max-retries-per-request", "Maximum number of retries for a single label/series API request; beyond this, the downstream error is returned.").
Default("5").IntVar(&cfg.LabelsConfig.MaxRetries)

cmd.Flag("query-range.max-query-length", "Limit the query time range (end - start time) in the query-frontend, 0 disables it.").
Default("0").DurationVar(&cfg.QueryRangeConfig.Limits.MaxQueryLength)

cmd.Flag("query-range.max-query-parallelism", "Maximum number of query range requests will be scheduled in parallel by the Frontend.").
Default("14").IntVar(&cfg.QueryRangeConfig.Limits.MaxQueryParallelism)
cmd.Flag("labels.max-query-parallelism", "Maximum number of labels requests will be scheduled in parallel by the Frontend.").
Default("14").IntVar(&cfg.LabelsConfig.Limits.MaxQueryParallelism)

cmd.Flag("query-range.response-cache-max-freshness", "Most recent allowed cacheable result for query range requests, to prevent caching very recent results that might still be in flux.").
Default("1m").DurationVar(&cfg.QueryRangeConfig.Limits.MaxCacheFreshness)
cmd.Flag("labels.response-cache-max-freshness", "Most recent allowed cacheable result for labels requests, to prevent caching very recent results that might still be in flux.").
Default("1m").DurationVar(&cfg.LabelsConfig.Limits.MaxCacheFreshness)

cmd.Flag("query-range.partial-response", "Enable partial response for query range requests if no partial_response param is specified. --no-query-range.partial-response for disabling.").
Default("true").BoolVar(&cfg.QueryRangeConfig.PartialResponseStrategy)

cfg.QueryRangeConfig.CachePathOrContent = *extflag.RegisterPathOrContent(cmd, "query-range.response-cache-config", "YAML file that contains response cache configuration.", false)

// Labels tripperware flags.
cmd.Flag("labels.split-interval", "Split labels requests by an interval and execute in parallel, it should be greater than 0 when labels.response-cache-config is configured.").
Default("24h").DurationVar(&cfg.LabelsConfig.SplitQueriesByInterval)

cmd.Flag("labels.max-retries-per-request", "Maximum number of retries for a single label/series API request; beyond this, the downstream error is returned.").
Default("5").IntVar(&cfg.LabelsConfig.MaxRetries)

cmd.Flag("labels.max-query-parallelism", "Maximum number of labels requests will be scheduled in parallel by the Frontend.").
Default("14").IntVar(&cfg.LabelsConfig.Limits.MaxQueryParallelism)

cmd.Flag("labels.response-cache-max-freshness", "Most recent allowed cacheable result for labels requests, to prevent caching very recent results that might still be in flux.").
Default("1m").DurationVar(&cfg.LabelsConfig.Limits.MaxCacheFreshness)

cmd.Flag("labels.partial-response", "Enable partial response for labels requests if no partial_response param is specified. --no-labels.partial-response for disabling.").
Default("true").BoolVar(&cfg.LabelsConfig.PartialResponseStrategy)

cmd.Flag("labels.default-time-range", "The default metadata time range duration for retrieving labels through Labels and Series API when the range parameters are not specified.").
Default("24h").DurationVar(&cfg.DefaultTimeRange)

cfg.QueryRangeConfig.CachePathOrContent = *extflag.RegisterPathOrContent(cmd, "query-range.response-cache-config", "YAML file that contains response cache configuration.", false)

cmd.Flag("cache-compression-type", "Use compression in results cache. Supported values are: 'snappy' and '' (disable compression).").
Default("").StringVar(&cfg.CacheCompression)

Expand Down
46 changes: 23 additions & 23 deletions docs/components/query-frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,48 +126,25 @@ Flags:
execute in parallel, it should be greater than
0 when query-range.response-cache-config is
configured.
--labels.split-interval=24h
Split labels requests by an interval and
execute in parallel, it should be greater than
0 when labels.response-cache-config is
configured.
--query-range.max-retries-per-request=5
Maximum number of retries for a single query
range request; beyond this, the downstream
error is returned.
--labels.max-retries-per-request=5
Maximum number of retries for a single
label/series API request; beyond this, the
downstream error is returned.
--query-range.max-query-length=0
Limit the query time range (end - start time)
in the query-frontend, 0 disables it.
--query-range.max-query-parallelism=14
Maximum number of query range requests will be
scheduled in parallel by the Frontend.
--labels.max-query-parallelism=14
Maximum number of labels requests will be
scheduled in parallel by the Frontend.
--query-range.response-cache-max-freshness=1m
Most recent allowed cacheable result for query
range requests, to prevent caching very recent
results that might still be in flux.
--labels.response-cache-max-freshness=1m
Most recent allowed cacheable result for labels
requests, to prevent caching very recent
results that might still be in flux.
--query-range.partial-response
Enable partial response for query range
requests if no partial_response param is
specified. --no-query-range.partial-response
for disabling.
--labels.partial-response Enable partial response for labels requests if
no partial_response param is specified.
--no-labels.partial-response for disabling.
--labels.default-time-range=24h
The default metadata time range duration for
retrieving labels through Labels and Series API
when the range parameters are not specified.
--query-range.response-cache-config-file=<file-path>
Path to YAML file that contains response cache
configuration.
Expand All @@ -176,6 +153,29 @@ Flags:
'query-range.response-cache-config-file' flag
(lower priority). Content of YAML file that
contains response cache configuration.
--labels.split-interval=24h
Split labels requests by an interval and
execute in parallel, it should be greater than
0 when labels.response-cache-config is
configured.
--labels.max-retries-per-request=5
Maximum number of retries for a single
label/series API request; beyond this, the
downstream error is returned.
--labels.max-query-parallelism=14
Maximum number of labels requests will be
scheduled in parallel by the Frontend.
--labels.response-cache-max-freshness=1m
Most recent allowed cacheable result for labels
requests, to prevent caching very recent
results that might still be in flux.
--labels.partial-response Enable partial response for labels requests if
no partial_response param is specified.
--no-labels.partial-response for disabling.
--labels.default-time-range=24h
The default metadata time range duration for
retrieving labels through Labels and Series API
when the range parameters are not specified.
--cache-compression-type=""
Use compression in results cache. Supported
values are: 'snappy' and ” (disable
Expand Down
2 changes: 2 additions & 0 deletions pkg/queryfrontend/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/prometheus/prometheus/pkg/timestamp"
)

// TODO(yeya24): add partial result when needed.
// ThanosRequest is a common interface defined for specific thanos requests.
type ThanosRequest interface {
GetStoreMatchers() [][]*labels.Matcher
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/queryfrontend/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewTripperware(config Config, reg prometheus.Registerer, logger log.Logger)
}

type roundTripper struct {
next, queryRange, metadata http.RoundTripper
next, queryRange, labels http.RoundTripper

queriesCount *prometheus.CounterVec
}
Expand All @@ -75,7 +75,7 @@ func newRoundTripper(next, queryRange, metadata http.RoundTripper, reg prometheu
r := roundTripper{
next: next,
queryRange: queryRange,
metadata: metadata,
labels: metadata,
queriesCount: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "thanos_query_frontend_queries_total",
Help: "Total queries passing through query frontend",
Expand All @@ -99,7 +99,7 @@ func (r roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return r.queryRange.RoundTrip(req)
case labelNamesOp, labelValuesOp, seriesOp:
r.queriesCount.WithLabelValues(op).Inc()
return r.metadata.RoundTrip(req)
return r.labels.RoundTrip(req)
default:
}

Expand Down

0 comments on commit 35380a9

Please sign in to comment.