Skip to content

Commit fbe1c63

Browse files
authored
Update prometheus to v2.16.0 (#2088)
* Updated Prometheus to 22a04239c937be61df95fdb60f0661684693cf3b (v2.16.0-rc.0) Signed-off-by: Peter Štibraný <[email protected]> * Added SelectSorted method. Signed-off-by: Peter Štibraný <[email protected]> * Use activity tracker to limit concurrency. Signed-off-by: Peter Štibraný <[email protected]> * Added SelectSorted method. Signed-off-by: Peter Štibraný <[email protected]> * Use ActiveQueryTracker for limiting concurrent queries. Signed-off-by: Peter Štibraný <[email protected]> * Added legacy_rulefmt from Prometheus, before latest change to yaml.Node. That change is currently incompatible with our serialization code, so until that is fixed, I've copied previous state of rulefmt from Prometheus (github.com/prometheus/prometheus/pkg/rulefmt). It's a small package, and I've included tests as well. Signed-off-by: Peter Štibraný <[email protected]> * Pass logger to activity tracker. Log directory for debugging. Signed-off-by: Peter Štibraný <[email protected]> * Renamed legacy_rulefmt package back to rulefmt. Signed-off-by: Peter Štibraný <[email protected]> * Use legacy_rulefmt import name. Signed-off-by: Peter Štibraný <[email protected]> * Clean tempdir after test has completed. Signed-off-by: Peter Štibraný <[email protected]> * Added -querier.active-query-tracker-dir flag Signed-off-by: Peter Štibraný <[email protected]> * Added CHANGELOG.md about new querier.active-query-tracker-dir flag Also explains why we use temp dir, if it's not configured. Signed-off-by: Peter Štibraný <[email protected]> * make doc Signed-off-by: Peter Štibraný <[email protected]> * Updated Prometheus to v2.16.0-rc.1 (56eaaadb54560d124310dcd779b81a4c5fe654cc) Signed-off-by: Peter Štibraný <[email protected]> * Updated Prometheus to 2.16.0 (b90be6f32a33c03163d700e1452b54454ddce0ec) Signed-off-by: Peter Štibraný <[email protected]> * Active query tracker documentation. Disable AQT if no directory is set. Signed-off-by: Peter Štibraný <[email protected]> * Updated CHANGELOG.md Signed-off-by: Peter Štibraný <[email protected]> * Swap Select and SelectSorted. Since our Select methods already return sorted results, it makes sense to call them SelectSorted, and let Select simply call SelectSorted, rather then the other way around. Signed-off-by: Peter Štibraný <[email protected]> * Updated docs Signed-off-by: Peter Štibraný <[email protected]> * No need to log directory used by active query tracker anymore. Signed-off-by: Peter Štibraný <[email protected]> * Ignore active-query-tracker, it is default dir name for Active Query Tracker Signed-off-by: Peter Štibraný <[email protected]> * Fixed active_query_tracker_dir yaml field name to match CLI option. Signed-off-by: Peter Štibraný <[email protected]> * Fake RemoteAddr if it is empty. Prometheus requires non-empty RemoteAddr, but only uses it when Engine actually has QueryLogger set. Which it doesn't, in Cortex. Signed-off-by: Peter Štibraný <[email protected]> * Add SelectSorted method to blocksQuerier. Signed-off-by: Peter Štibraný <[email protected]> * Added comment about possible removal in the future. Signed-off-by: Peter Štibraný <[email protected]> * Fix compilation and test issues after master rebase. Signed-off-by: Peter Štibraný <[email protected]> * Go mod tidy Signed-off-by: Peter Štibraný <[email protected]> * Lint Signed-off-by: Peter Štibraný <[email protected]> * Review feedback. Also fixed impls -> implements. Signed-off-by: Peter Štibraný <[email protected]>
1 parent dbf9266 commit fbe1c63

File tree

114 files changed

+15055
-1929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+15055
-1929
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ docker-images/
77
website/public
88
website/resources
99
website/content/en/docs
10-
e2e_integration_test*
10+
e2e_integration_test*
11+
active-query-tracker
12+

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [CHANGE] Experimental Memberlist KV store can now be used in single-binary Cortex. Attempts to use it previously would fail with panic. This change also breaks existing binary protocol used to exchange gossip messages, so this version will not be able to understand gossiped Ring when used in combination with the previous version of Cortex. Easiest way to upgrade is to shutdown old Cortex installation, and restart it with new version. Incremental rollout works too, but with reduced functionality until all components run the same version. #2016
2323
* [CHANGE] Renamed the cache configuration setting `defaul_validity` to `default_validity`. #2140
2424
* [CHANGE] Removed unused /validate_expr endpoint. #2152
25+
* [CHANGE] Updated Prometheus dependency to v2.16.0. This Prometheus version uses Active Query Tracker to limit concurrent queries. In order to keep `-querier.max-concurrent` working, Active Query Tracker is enabled by default, and is configured to store its data to `active-query-tracker` directory (relative to current directory when Cortex started). This can be changed by using `-querier.active-query-tracker-dir` option. Purpose of Active Query Tracker is to log queries that were running when Cortex crashes. This logging happens on next Cortex start. #2088
2526
* [FEATURE] Added a read-only local alertmanager config store using files named corresponding to their tenant id. #2125
2627
* [FEATURE] Added user sub rings to distribute users to a subset of ingesters. #1947
2728
* `--experimental.distributor.user-subring-size`

docs/configuration/config-file-reference.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ The `querier_config` configures the Cortex querier.
569569
# The default evaluation interval or step size for subqueries.
570570
# CLI flag: -querier.default-evaluation-interval
571571
[defaultevaluationinterval: <duration> | default = 1m0s]
572+
573+
# Active query tracker monitors active queries, and writes them to the file in
574+
# given directory. If Cortex discovers any queries in this log during startup,
575+
# it will log them to the log file. Setting to empty value disables active query
576+
# tracker, which also disables -querier.max-concurrent option.
577+
# CLI flag: -querier.active-query-tracker-dir
578+
[active_query_tracker_dir: <string> | default = "./active-query-tracker"]
572579
```
573580

574581
## `query_frontend_config`

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ require (
5252
github.com/prometheus/alertmanager v0.19.0
5353
github.com/prometheus/client_golang v1.2.1
5454
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4
55-
github.com/prometheus/common v0.7.0
56-
github.com/prometheus/prometheus v1.8.2-0.20200107122003-4708915ac6ef
55+
github.com/prometheus/common v0.8.0
56+
github.com/prometheus/prometheus v1.8.2-0.20200213233353-b90be6f32a33
5757
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1
5858
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
5959
github.com/spf13/afero v1.2.2
@@ -71,7 +71,7 @@ require (
7171
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
7272
google.golang.org/api v0.14.0
7373
google.golang.org/grpc v1.25.1
74-
gopkg.in/yaml.v2 v2.2.5
74+
gopkg.in/yaml.v2 v2.2.7
7575
sigs.k8s.io/yaml v1.1.0
7676
)
7777

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
671671
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
672672
github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY=
673673
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
674+
github.com/prometheus/common v0.8.0 h1:bLkjvFe2ZRX1DpcgZcdf7j/+MnusEps5hktST/FHA34=
675+
github.com/prometheus/common v0.8.0/go.mod h1:PC/OgXc+UN7B4ALwvn1yzVZmVwvhXp5JsbBv6wSv6i0=
674676
github.com/prometheus/procfs v0.0.0-20180612222113-7d6f385de8be/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
675677
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
676678
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
@@ -686,6 +688,8 @@ github.com/prometheus/prometheus v0.0.0-20180315085919-58e2a31db8de/go.mod h1:oA
686688
github.com/prometheus/prometheus v0.0.0-20190818123050-43acd0e2e93f/go.mod h1:rMTlmxGCvukf2KMu3fClMDKLLoJ5hl61MhcJ7xKakf0=
687689
github.com/prometheus/prometheus v1.8.2-0.20200107122003-4708915ac6ef h1:pYYKXo/zGx25kyViw+Gdbxd0ItIg+vkVKpwgWUEyIc4=
688690
github.com/prometheus/prometheus v1.8.2-0.20200107122003-4708915ac6ef/go.mod h1:7U90zPoLkWjEIQcy/rweQla82OCTUzxVHE51G3OhJbI=
691+
github.com/prometheus/prometheus v1.8.2-0.20200213233353-b90be6f32a33 h1:HBYrMJj5iosUjUkAK9L5GO+5eEQXbcrzdjkqY9HV5W4=
692+
github.com/prometheus/prometheus v1.8.2-0.20200213233353-b90be6f32a33/go.mod h1:fkIPPkuZnkXyopYHmXPxf9rgiPkVgZCN8w9o8+UgBlY=
689693
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1 h1:+kGqA4dNN5hn7WwvKdzHl0rdN5AEkbNZd0VjRltAiZg=
690694
github.com/rafaeljusto/redigomock v0.0.0-20190202135759-257e089e14a1/go.mod h1:JaY6n2sDr+z2WTsXkOmNRUfDy6FN0L6Nk7x06ndm4tY=
691695
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
@@ -1064,6 +1068,10 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
10641068
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
10651069
gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c=
10661070
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
1071+
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
1072+
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
1073+
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2 h1:XZx7nhd5GMaZpmDaEHFVafUZC7ya0fuo7cSJ3UCKYmM=
1074+
gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10671075
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
10681076
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
10691077
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

pkg/configs/configs.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"github.com/go-kit/kit/log"
99
"github.com/prometheus/common/model"
1010
"github.com/prometheus/prometheus/pkg/labels"
11-
"github.com/prometheus/prometheus/pkg/rulefmt"
1211
"github.com/prometheus/prometheus/promql"
1312
"github.com/prometheus/prometheus/rules"
1413

1514
legacy_promql "github.com/cortexproject/cortex/pkg/configs/legacy_promql"
15+
legacy_rulefmt "github.com/cortexproject/cortex/pkg/ruler/legacy_rulefmt"
1616
"github.com/cortexproject/cortex/pkg/util"
1717
)
1818

@@ -185,7 +185,7 @@ func (c RulesConfig) Parse() (map[string][]rules.Rule, error) {
185185

186186
// ParseFormatted returns the rulefmt map of a users rules configs. It allows
187187
// for rules to be mapped to disk and read by the prometheus rules manager.
188-
func (c RulesConfig) ParseFormatted() (map[string]rulefmt.RuleGroups, error) {
188+
func (c RulesConfig) ParseFormatted() (map[string]legacy_rulefmt.RuleGroups, error) {
189189
switch c.FormatVersion {
190190
case RuleFormatV1:
191191
return c.parseV1Formatted()
@@ -198,11 +198,11 @@ func (c RulesConfig) ParseFormatted() (map[string]rulefmt.RuleGroups, error) {
198198

199199
// parseV2 parses and validates the content of the rule files in a RulesConfig
200200
// according to the Prometheus 2.x rule format.
201-
func (c RulesConfig) parseV2Formatted() (map[string]rulefmt.RuleGroups, error) {
202-
ruleMap := map[string]rulefmt.RuleGroups{}
201+
func (c RulesConfig) parseV2Formatted() (map[string]legacy_rulefmt.RuleGroups, error) {
202+
ruleMap := map[string]legacy_rulefmt.RuleGroups{}
203203

204204
for fn, content := range c.Files {
205-
rgs, errs := rulefmt.Parse([]byte(content))
205+
rgs, errs := legacy_rulefmt.Parse([]byte(content))
206206
for _, err := range errs { // return just the first error, if any
207207
return nil, err
208208
}
@@ -214,25 +214,25 @@ func (c RulesConfig) parseV2Formatted() (map[string]rulefmt.RuleGroups, error) {
214214

215215
// parseV1 parses and validates the content of the rule files in a RulesConfig
216216
// according to the Prometheus 1.x rule format.
217-
func (c RulesConfig) parseV1Formatted() (map[string]rulefmt.RuleGroups, error) {
218-
result := map[string]rulefmt.RuleGroups{}
217+
func (c RulesConfig) parseV1Formatted() (map[string]legacy_rulefmt.RuleGroups, error) {
218+
result := map[string]legacy_rulefmt.RuleGroups{}
219219
for fn, content := range c.Files {
220220
stmts, err := legacy_promql.ParseStmts(content)
221221
if err != nil {
222222
return nil, fmt.Errorf("error parsing %s: %s", fn, err)
223223
}
224224

225-
ra := []rulefmt.Rule{}
225+
ra := []legacy_rulefmt.Rule{}
226226
for _, stmt := range stmts {
227-
var rule rulefmt.Rule
227+
var rule legacy_rulefmt.Rule
228228
switch r := stmt.(type) {
229229
case *legacy_promql.AlertStmt:
230230
_, err := promql.ParseExpr(r.Expr.String())
231231
if err != nil {
232232
return nil, err
233233
}
234234

235-
rule = rulefmt.Rule{
235+
rule = legacy_rulefmt.Rule{
236236
Alert: r.Name,
237237
Expr: r.Expr.String(),
238238
For: model.Duration(r.Duration),
@@ -246,7 +246,7 @@ func (c RulesConfig) parseV1Formatted() (map[string]rulefmt.RuleGroups, error) {
246246
return nil, err
247247
}
248248

249-
rule = rulefmt.Rule{
249+
rule = legacy_rulefmt.Rule{
250250
Record: r.Name,
251251
Expr: r.Expr.String(),
252252
Labels: r.Labels.Map(),
@@ -257,8 +257,8 @@ func (c RulesConfig) parseV1Formatted() (map[string]rulefmt.RuleGroups, error) {
257257
}
258258
ra = append(ra, rule)
259259
}
260-
result[fn] = rulefmt.RuleGroups{
261-
Groups: []rulefmt.RuleGroup{
260+
result[fn] = legacy_rulefmt.RuleGroups{
261+
Groups: []legacy_rulefmt.RuleGroup{
262262
{
263263
Name: "rg:" + fn,
264264
Rules: ra,
@@ -286,7 +286,7 @@ func (c RulesConfig) parseV2() (map[string][]rules.Rule, error) {
286286
groups := map[string][]rules.Rule{}
287287

288288
for fn, content := range c.Files {
289-
rgs, errs := rulefmt.Parse([]byte(content))
289+
rgs, errs := legacy_rulefmt.Parse([]byte(content))
290290
if len(errs) > 0 {
291291
return nil, fmt.Errorf("error parsing %s: %v", fn, errs[0])
292292
}

pkg/configs/configs_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99
"github.com/go-kit/kit/log"
1010
"github.com/prometheus/common/model"
1111
"github.com/prometheus/prometheus/pkg/labels"
12-
"github.com/prometheus/prometheus/pkg/rulefmt"
1312
"github.com/prometheus/prometheus/promql"
1413
"github.com/prometheus/prometheus/rules"
1514
"github.com/stretchr/testify/assert"
1615
"github.com/stretchr/testify/require"
1716

17+
legacy_rulefmt "github.com/cortexproject/cortex/pkg/ruler/legacy_rulefmt"
1818
"github.com/cortexproject/cortex/pkg/util"
1919
)
2020

@@ -130,7 +130,7 @@ func TestParseFormatted(t *testing.T) {
130130
dur, err := model.ParseDuration("5m")
131131
require.NoError(t, err)
132132

133-
rules := []rulefmt.Rule{
133+
rules := []legacy_rulefmt.Rule{
134134
{
135135
Alert: "TestAlert",
136136
Expr: "up == 0",
@@ -146,7 +146,7 @@ func TestParseFormatted(t *testing.T) {
146146

147147
for i, tc := range []struct {
148148
cfg RulesConfig
149-
expected map[string]rulefmt.RuleGroups
149+
expected map[string]legacy_rulefmt.RuleGroups
150150
}{
151151
{
152152
cfg: RulesConfig{
@@ -155,9 +155,9 @@ func TestParseFormatted(t *testing.T) {
155155
"legacy.rules": legacyRulesFile,
156156
},
157157
},
158-
expected: map[string]rulefmt.RuleGroups{
158+
expected: map[string]legacy_rulefmt.RuleGroups{
159159
"legacy.rules": {
160-
Groups: []rulefmt.RuleGroup{
160+
Groups: []legacy_rulefmt.RuleGroup{
161161
{
162162
Name: "rg:legacy.rules",
163163
Rules: rules,
@@ -173,9 +173,9 @@ func TestParseFormatted(t *testing.T) {
173173
"alerts.yaml": ruleFile,
174174
},
175175
},
176-
expected: map[string]rulefmt.RuleGroups{
176+
expected: map[string]legacy_rulefmt.RuleGroups{
177177
"alerts.yaml": {
178-
Groups: []rulefmt.RuleGroup{
178+
Groups: []legacy_rulefmt.RuleGroup{
179179
{
180180
Name: "example",
181181
Rules: rules,

pkg/configs/legacy_promql/engine_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ type errQuerier struct {
132132
func (q *errQuerier) Select(*storage.SelectParams, ...*labels.Matcher) (storage.SeriesSet, storage.Warnings, error) {
133133
return errSeriesSet{err: q.err}, nil, q.err
134134
}
135+
func (q *errQuerier) SelectSorted(*storage.SelectParams, ...*labels.Matcher) (storage.SeriesSet, storage.Warnings, error) {
136+
return errSeriesSet{err: q.err}, nil, q.err
137+
}
135138
func (q *errQuerier) LabelValues(name string) ([]string, storage.Warnings, error) {
136139
return nil, nil, q.err
137140
}

pkg/cortex/modules.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cortex
33
import (
44
"errors"
55
"fmt"
6-
"math"
76
"net/http"
87
"os"
98
"regexp"
@@ -262,7 +261,7 @@ func (t *Cortex) initQuerier(cfg *Config) (err error) {
262261
api.Register(promRouter)
263262

264263
subrouter := t.server.HTTP.PathPrefix("/api/prom").Subrouter()
265-
subrouter.PathPrefix("/api/v1").Handler(t.httpAuthMiddleware.Wrap(promRouter))
264+
subrouter.PathPrefix("/api/v1").Handler(fakeRemoteAddr(t.httpAuthMiddleware.Wrap(promRouter)))
266265
subrouter.Path("/read").Handler(t.httpAuthMiddleware.Wrap(querier.RemoteReadHandler(queryable)))
267266
subrouter.Path("/chunks").Handler(t.httpAuthMiddleware.Wrap(querier.ChunksHandler(queryable)))
268267
subrouter.Path("/user_stats").Handler(middleware.AuthenticateUser.Wrap(http.HandlerFunc(t.distributor.UserStatsHandler)))
@@ -283,6 +282,20 @@ func (t *Cortex) initQuerier(cfg *Config) (err error) {
283282
return
284283
}
285284

285+
// Latest Prometheus requires r.RemoteAddr to be set to addr:port, otherwise it reject the request.
286+
// Requests to Querier sometimes doesn't have that (if they are fetched from Query-Frontend).
287+
// Prometheus uses this when logging queries to QueryLogger, but Cortex doesn't call engine.SetQueryLogger to set one.
288+
//
289+
// Can be removed when (if) https://github.com/prometheus/prometheus/pull/6840 is merged.
290+
func fakeRemoteAddr(handler http.Handler) http.Handler {
291+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
292+
if r.RemoteAddr == "" {
293+
r.RemoteAddr = "127.0.0.1:8888"
294+
}
295+
handler.ServeHTTP(w, r)
296+
})
297+
}
298+
286299
func (t *Cortex) stopQuerier() error {
287300
t.worker.Stop()
288301
return nil
@@ -374,11 +387,10 @@ func (t *Cortex) initQueryFrontend(cfg *Config) (err error) {
374387
queryrange.PrometheusResponseExtractor,
375388
cfg.Schema,
376389
promql.EngineOpts{
377-
Logger: util.Logger,
378-
Reg: prometheus.DefaultRegisterer,
379-
MaxConcurrent: int(math.MaxInt64), // the frontend's promql engine should not set any concurrency controls (these are handled by middleware)
380-
MaxSamples: cfg.Querier.MaxSamples,
381-
Timeout: cfg.Querier.Timeout,
390+
Logger: util.Logger,
391+
Reg: prometheus.DefaultRegisterer,
392+
MaxSamples: cfg.Querier.MaxSamples,
393+
Timeout: cfg.Querier.Timeout,
382394
},
383395
cfg.Querier.QueryIngestersWithin,
384396
)

pkg/querier/astmapper/astmapper_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func TestCloneNode(t *testing.T) {
2424
},
2525
&promql.BinaryExpr{
2626
Op: promql.ADD,
27-
LHS: &promql.NumberLiteral{Val: 1},
28-
RHS: &promql.NumberLiteral{Val: 1},
27+
LHS: &promql.NumberLiteral{Val: 1, PosRange: promql.PositionRange{Start: 0, End: 1}},
28+
RHS: &promql.NumberLiteral{Val: 1, PosRange: promql.PositionRange{Start: 4, End: 5}},
2929
},
3030
},
3131
{
@@ -48,8 +48,16 @@ func TestCloneNode(t *testing.T) {
4848
LabelMatchers: []*labels.Matcher{
4949
mustLabelMatcher(labels.MatchEqual, string(model.MetricNameLabel), "some_metric"),
5050
},
51+
PosRange: promql.PositionRange{
52+
Start: 18,
53+
End: 29,
54+
},
5155
},
5256
Grouping: []string{"foo"},
57+
PosRange: promql.PositionRange{
58+
Start: 0,
59+
End: 30,
60+
},
5361
},
5462
},
5563
}

0 commit comments

Comments
 (0)