diff --git a/CHANGELOG.md b/CHANGELOG.md index 2814bbac21..d5910deb72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6466](https://github.com/thanos-io/thanos/pull/6466) Mixin (Receive): add limits alerting for configuration reload and meta-monitoring. - [#6467](https://github.com/thanos-io/thanos/pull/6467) Mixin (Receive): add alert for tenant reaching head series limit. - [#6528](https://github.com/thanos-io/thanos/pull/6528) Index Cache: Add histogram metric `thanos_store_index_cache_stored_data_size_bytes` for item size. +- [#6560](https://github.com/thanos-io/thanos/pull/6560) Thanos ruler: add flag to optionally disable adding Thanos params when querying metrics ### Fixed - [#6503](https://github.com/thanos-io/thanos/pull/6503) *: Change the engine behind `ContentPathReloader` to be completely independent of any filesystem concept. This effectively fixes this configuration reload when used with Kubernetes ConfigMaps, Secrets, or other volume mounts. diff --git a/cmd/thanos/config.go b/cmd/thanos/config.go index 4986de9af8..05e510d8b8 100644 --- a/cmd/thanos/config.go +++ b/cmd/thanos/config.go @@ -180,14 +180,15 @@ func (wc *webConfig) registerFlag(cmd extkingpin.FlagClause) *webConfig { } type queryConfig struct { - addrs []string - sdFiles []string - sdInterval time.Duration - configPath *extflag.PathOrContent - dnsSDInterval time.Duration - httpMethod string - dnsSDResolver string - step time.Duration + addrs []string + sdFiles []string + sdInterval time.Duration + configPath *extflag.PathOrContent + dnsSDInterval time.Duration + httpMethod string + dnsSDResolver string + step time.Duration + doNotAddThanosParams bool } func (qc *queryConfig) registerFlag(cmd extkingpin.FlagClause) *queryConfig { @@ -206,6 +207,8 @@ func (qc *queryConfig) registerFlag(cmd extkingpin.FlagClause) *queryConfig { Default("miekgdns").Hidden().StringVar(&qc.dnsSDResolver) cmd.Flag("query.default-step", "Default range query step to use. This is only used in stateless Ruler and alert state restoration."). Default("1s").DurationVar(&qc.step) + cmd.Flag("query.only-prometheus-params", "Disable adding Thanos parameters (e.g dedup, partial_response) when querying metrics. Some non-Thanos systems have strict API validation.").Hidden(). + Default("false").BoolVar(&qc.doNotAddThanosParams) return qc } diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 6f507f82ca..9272121a7d 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -525,7 +525,7 @@ func runRule( OutageTolerance: conf.outageTolerance, ForGracePeriod: conf.forGracePeriod, }, - queryFuncCreator(logger, queryClients, promClients, metrics.duplicatedQuery, metrics.ruleEvalWarnings, conf.query.httpMethod), + queryFuncCreator(logger, queryClients, promClients, metrics.duplicatedQuery, metrics.ruleEvalWarnings, conf.query.httpMethod, conf.query.doNotAddThanosParams), conf.lset, // In our case the querying URL is the external URL because in Prometheus // --web.external-url points to it i.e. it points at something where the user @@ -808,6 +808,7 @@ func queryFuncCreator( duplicatedQuery prometheus.Counter, ruleEvalWarnings *prometheus.CounterVec, httpMethod string, + doNotAddThanosParams bool, ) func(partialResponseStrategy storepb.PartialResponseStrategy) rules.QueryFunc { // queryFunc returns query function that hits the HTTP query API of query peers in randomized order until we get a result @@ -835,6 +836,7 @@ func queryFuncCreator( Deduplicate: true, PartialResponseStrategy: partialResponseStrategy, Method: httpMethod, + DoNotAddThanosParams: doNotAddThanosParams, }) span.Finish() diff --git a/pkg/promclient/promclient.go b/pkg/promclient/promclient.go index 29d5b3f044..f564fade72 100644 --- a/pkg/promclient/promclient.go +++ b/pkg/promclient/promclient.go @@ -356,6 +356,7 @@ func (c *Client) Snapshot(ctx context.Context, base *url.URL, skipHead bool) (st } type QueryOptions struct { + DoNotAddThanosParams bool Deduplicate bool PartialResponseStrategy storepb.PartialResponseStrategy Method string @@ -402,8 +403,10 @@ func (c *Client) QueryInstant(ctx context.Context, base *url.URL, query string, } params.Add("query", query) params.Add("time", t.Format(time.RFC3339Nano)) - if err := opts.AddTo(params); err != nil { - return nil, nil, nil, errors.Wrap(err, "add thanos opts query params") + if !opts.DoNotAddThanosParams { + if err := opts.AddTo(params); err != nil { + return nil, nil, nil, errors.Wrap(err, "add thanos opts query params") + } } u := *base @@ -511,8 +514,10 @@ func (c *Client) QueryRange(ctx context.Context, base *url.URL, query string, st params.Add("start", formatTime(timestamp.Time(startTime))) params.Add("end", formatTime(timestamp.Time(endTime))) params.Add("step", strconv.FormatInt(step, 10)) - if err := opts.AddTo(params); err != nil { - return nil, nil, nil, errors.Wrap(err, "add thanos opts query params") + if !opts.DoNotAddThanosParams { + if err := opts.AddTo(params); err != nil { + return nil, nil, nil, errors.Wrap(err, "add thanos opts query params") + } } u := *base