Skip to content

Commit e32205a

Browse files
committed
Deprecate query_store_for_labels_enabled
1 parent 32bd46f commit e32205a

File tree

8 files changed

+25
-79
lines changed

8 files changed

+25
-79
lines changed

docs/blocks-storage/querier.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ querier:
117117
# CLI flag: -querier.query-ingesters-within
118118
[query_ingesters_within: <duration> | default = 0s]
119119

120-
# Deprecated (Querying long-term store for labels will be always enabled in
121-
# the future.): Query long-term store for series, label values and label names
122-
# APIs.
123-
# CLI flag: -querier.query-store-for-labels-enabled
124-
[query_store_for_labels_enabled: <boolean> | default = false]
125-
126120
# Enable returning samples stats per steps in query response.
127121
# CLI flag: -querier.per-step-stats-enabled
128122
[per_step_stats_enabled: <boolean> | default = false]

docs/configuration/config-file-reference.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3644,11 +3644,6 @@ The `querier_config` configures the Cortex querier.
36443644
# CLI flag: -querier.query-ingesters-within
36453645
[query_ingesters_within: <duration> | default = 0s]
36463646
3647-
# Deprecated (Querying long-term store for labels will be always enabled in the
3648-
# future.): Query long-term store for series, label values and label names APIs.
3649-
# CLI flag: -querier.query-store-for-labels-enabled
3650-
[query_store_for_labels_enabled: <boolean> | default = false]
3651-
36523647
# Enable returning samples stats per steps in query response.
36533648
# CLI flag: -querier.per-step-stats-enabled
36543649
[per_step_stats_enabled: <boolean> | default = false]

pkg/cortex/modules.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ func (t *Cortex) initIngesterService() (serv services.Service, err error) {
403403
t.Cfg.Ingester.DistributorShardingStrategy = t.Cfg.Distributor.ShardingStrategy
404404
t.Cfg.Ingester.DistributorShardByAllLabels = t.Cfg.Distributor.ShardByAllLabels
405405
t.Cfg.Ingester.InstanceLimitsFn = ingesterInstanceLimits(t.RuntimeConfig)
406-
t.Cfg.Ingester.QueryStoreForLabels = t.Cfg.Querier.QueryStoreForLabels
407406
t.Cfg.Ingester.QueryIngestersWithin = t.Cfg.Querier.QueryIngestersWithin
408407
t.tsdbIngesterConfig()
409408

pkg/ingester/ingester.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ type Config struct {
120120
DistributorShardByAllLabels bool `yaml:"-"`
121121

122122
// Injected at runtime and read from querier config.
123-
QueryStoreForLabels bool `yaml:"-"`
124123
QueryIngestersWithin time.Duration `yaml:"-"`
125124

126125
DefaultLimits InstanceLimits `yaml:"instance_limits"`
@@ -1426,7 +1425,7 @@ func (i *Ingester) labelsValuesCommon(ctx context.Context, req *client.LabelValu
14261425
return &client.LabelValuesResponse{}, cleanup, nil
14271426
}
14281427

1429-
mint, maxt, err := metadataQueryRange(startTimestampMs, endTimestampMs, db, i.cfg.QueryStoreForLabels, i.cfg.QueryIngestersWithin)
1428+
mint, maxt, err := metadataQueryRange(startTimestampMs, endTimestampMs, db, i.cfg.QueryIngestersWithin)
14301429
if err != nil {
14311430
return nil, cleanup, err
14321431
}
@@ -1506,7 +1505,7 @@ func (i *Ingester) labelNamesCommon(ctx context.Context, req *client.LabelNamesR
15061505
return &client.LabelNamesResponse{}, cleanup, nil
15071506
}
15081507

1509-
mint, maxt, err := metadataQueryRange(req.StartTimestampMs, req.EndTimestampMs, db, i.cfg.QueryStoreForLabels, i.cfg.QueryIngestersWithin)
1508+
mint, maxt, err := metadataQueryRange(req.StartTimestampMs, req.EndTimestampMs, db, i.cfg.QueryIngestersWithin)
15101509
if err != nil {
15111510
return nil, cleanup, err
15121511
}
@@ -1586,7 +1585,7 @@ func (i *Ingester) metricsForLabelMatchersCommon(ctx context.Context, req *clien
15861585
return nil, cleanup, err
15871586
}
15881587

1589-
mint, maxt, err := metadataQueryRange(req.StartTimestampMs, req.EndTimestampMs, db, i.cfg.QueryStoreForLabels, i.cfg.QueryIngestersWithin)
1588+
mint, maxt, err := metadataQueryRange(req.StartTimestampMs, req.EndTimestampMs, db, i.cfg.QueryIngestersWithin)
15901589
if err != nil {
15911590
return nil, cleanup, err
15921591
}
@@ -2755,8 +2754,8 @@ func (i *Ingester) flushHandler(w http.ResponseWriter, r *http.Request) {
27552754
}
27562755

27572756
// metadataQueryRange returns the best range to query for metadata queries based on the timerange in the ingester.
2758-
func metadataQueryRange(queryStart, queryEnd int64, db *userTSDB, queryStoreForLabels bool, queryIngestersWithin time.Duration) (mint, maxt int64, err error) {
2759-
if queryIngestersWithin > 0 && queryStoreForLabels {
2757+
func metadataQueryRange(queryStart, queryEnd int64, db *userTSDB, queryIngestersWithin time.Duration) (mint, maxt int64, err error) {
2758+
if queryIngestersWithin > 0 {
27602759
// If the feature for querying metadata from store-gateway is enabled,
27612760
// then we don't want to manipulate the mint and maxt.
27622761
return queryStart, queryEnd, nil

pkg/querier/distributor_queryable.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ type Distributor interface {
3636
MetricsMetadata(ctx context.Context) ([]scrape.MetricMetadata, error)
3737
}
3838

39-
func newDistributorQueryable(distributor Distributor, streamingMetdata bool, iteratorFn chunkIteratorFunc, queryIngestersWithin time.Duration, queryStoreForLabels bool) QueryableWithFilter {
39+
func newDistributorQueryable(distributor Distributor, streamingMetdata bool, iteratorFn chunkIteratorFunc, queryIngestersWithin time.Duration) QueryableWithFilter {
4040
return distributorQueryable{
4141
distributor: distributor,
4242
streamingMetdata: streamingMetdata,
4343
iteratorFn: iteratorFn,
4444
queryIngestersWithin: queryIngestersWithin,
45-
queryStoreForLabels: queryStoreForLabels,
4645
}
4746
}
4847

@@ -51,7 +50,6 @@ type distributorQueryable struct {
5150
streamingMetdata bool
5251
iteratorFn chunkIteratorFunc
5352
queryIngestersWithin time.Duration
54-
queryStoreForLabels bool
5553
}
5654

5755
func (d distributorQueryable) Querier(mint, maxt int64) (storage.Querier, error) {
@@ -62,7 +60,6 @@ func (d distributorQueryable) Querier(mint, maxt int64) (storage.Querier, error)
6260
streamingMetadata: d.streamingMetdata,
6361
chunkIterFn: d.iteratorFn,
6462
queryIngestersWithin: d.queryIngestersWithin,
65-
queryStoreForLabels: d.queryStoreForLabels,
6663
}, nil
6764
}
6865

@@ -77,7 +74,6 @@ type distributorQuerier struct {
7774
streamingMetadata bool
7875
chunkIterFn chunkIteratorFunc
7976
queryIngestersWithin time.Duration
80-
queryStoreForLabels bool
8177
}
8278

8379
// Select implements storage.Querier interface.
@@ -91,19 +87,11 @@ func (q *distributorQuerier) Select(ctx context.Context, sortSeries bool, sp *st
9187
minT, maxT = sp.Start, sp.End
9288
}
9389

94-
// If the querier receives a 'series' query, it means only metadata is needed.
95-
// For the specific case where queryStoreForLabels is disabled
96-
// we shouldn't apply the queryIngestersWithin time range manipulation.
97-
// Otherwise we'll end up returning no series at all for
98-
// older time ranges (while in Cortex we do ignore the start/end and always return
99-
// series in ingesters).
100-
shouldNotQueryStoreForMetadata := (sp != nil && sp.Func == "series" && !q.queryStoreForLabels)
101-
102-
// If queryIngestersWithin is enabled, we do manipulate the query mint to query samples up until
90+
// We should manipulate the query mint to query samples up until
10391
// now - queryIngestersWithin, because older time ranges are covered by the storage. This
10492
// optimization is particularly important for the blocks storage where the blocks retention in the
10593
// ingesters could be way higher than queryIngestersWithin.
106-
if q.queryIngestersWithin > 0 && !shouldNotQueryStoreForMetadata {
94+
if q.queryIngestersWithin > 0 {
10795
now := time.Now()
10896
origMinT := minT
10997
minT = max(minT, util.TimeToMillis(now.Add(-q.queryIngestersWithin)))

pkg/querier/distributor_queryable_test.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func TestDistributorQuerier_SelectShouldHonorQueryIngestersWithin(t *testing.T)
3434

3535
tests := map[string]struct {
3636
querySeries bool
37-
queryStoreForLabels bool
3837
queryIngestersWithin time.Duration
3938
queryMinT int64
4039
queryMaxT int64
@@ -69,19 +68,10 @@ func TestDistributorQuerier_SelectShouldHonorQueryIngestersWithin(t *testing.T)
6968
expectedMinT: 0,
7069
expectedMaxT: 0,
7170
},
72-
"should not manipulate query time range if queryIngestersWithin is enabled and query max time is older, but the query is for /series": {
71+
"should manipulate query time range if queryIngestersWithin is enabled": {
7372
querySeries: true,
7473
queryIngestersWithin: time.Hour,
7574
queryMinT: util.TimeToMillis(now.Add(-100 * time.Minute)),
76-
queryMaxT: util.TimeToMillis(now.Add(-90 * time.Minute)),
77-
expectedMinT: util.TimeToMillis(now.Add(-100 * time.Minute)),
78-
expectedMaxT: util.TimeToMillis(now.Add(-90 * time.Minute)),
79-
},
80-
"should manipulate query time range if queryIngestersWithin is enabled and queryStoreForLabels is enabled": {
81-
querySeries: true,
82-
queryStoreForLabels: true,
83-
queryIngestersWithin: time.Hour,
84-
queryMinT: util.TimeToMillis(now.Add(-100 * time.Minute)),
8575
queryMaxT: util.TimeToMillis(now.Add(-30 * time.Minute)),
8676
expectedMinT: util.TimeToMillis(now.Add(-60 * time.Minute)),
8777
expectedMaxT: util.TimeToMillis(now.Add(-30 * time.Minute)),
@@ -100,7 +90,7 @@ func TestDistributorQuerier_SelectShouldHonorQueryIngestersWithin(t *testing.T)
10090
distributor.On("MetricsForLabelMatchersStream", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]model.Metric{}, nil)
10191

10292
ctx := user.InjectOrgID(context.Background(), "test")
103-
queryable := newDistributorQueryable(distributor, streamingMetadataEnabled, nil, testData.queryIngestersWithin, testData.queryStoreForLabels)
93+
queryable := newDistributorQueryable(distributor, streamingMetadataEnabled, nil, testData.queryIngestersWithin)
10494
querier, err := queryable.Querier(testData.queryMinT, testData.queryMaxT)
10595
require.NoError(t, err)
10696

@@ -139,7 +129,7 @@ func TestDistributorQueryableFilter(t *testing.T) {
139129
t.Parallel()
140130

141131
d := &MockDistributor{}
142-
dq := newDistributorQueryable(d, false, nil, 1*time.Hour, true)
132+
dq := newDistributorQueryable(d, false, nil, 1*time.Hour)
143133

144134
now := time.Now()
145135

@@ -189,7 +179,7 @@ func TestIngesterStreaming(t *testing.T) {
189179
nil)
190180

191181
ctx := user.InjectOrgID(context.Background(), "0")
192-
queryable := newDistributorQueryable(d, true, batch.NewChunkMergeIterator, 0, true)
182+
queryable := newDistributorQueryable(d, true, batch.NewChunkMergeIterator, 0)
193183
querier, err := queryable.Querier(mint, maxt)
194184
require.NoError(t, err)
195185

@@ -230,7 +220,7 @@ func TestDistributorQuerier_LabelNames(t *testing.T) {
230220
d.On("MetricsForLabelMatchersStream", mock.Anything, model.Time(mint), model.Time(maxt), someMatchers).
231221
Return(metrics, nil)
232222

233-
queryable := newDistributorQueryable(d, streamingEnabled, nil, 0, true)
223+
queryable := newDistributorQueryable(d, streamingEnabled, nil, 0)
234224
querier, err := queryable.Querier(mint, maxt)
235225
require.NoError(t, err)
236226

pkg/querier/querier.go

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type Config struct {
4747
IngesterMetadataStreaming bool `yaml:"ingester_metadata_streaming"`
4848
MaxSamples int `yaml:"max_samples"`
4949
QueryIngestersWithin time.Duration `yaml:"query_ingesters_within"`
50-
QueryStoreForLabels bool `yaml:"query_store_for_labels_enabled"`
5150
AtModifierEnabled bool `yaml:"at_modifier_enabled" doc:"hidden"`
5251
EnablePerStepStats bool `yaml:"per_step_stats_enabled"`
5352

@@ -103,14 +102,15 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
103102
flagext.DeprecatedFlag(f, "querier.iterators", "Deprecated: Use iterators to execute query. This flag is no longer functional; Batch iterator is always enabled instead.", util_log.Logger)
104103
//lint:ignore faillint Need to pass the global logger like this for warning on deprecated methods
105104
flagext.DeprecatedFlag(f, "querier.batch-iterators", "Deprecated: Use batch iterators to execute query. This flag is no longer functional; Batch iterator is always enabled now.", util_log.Logger)
105+
//lint:ignore faillint Need to pass the global logger like this for warning on deprecated methods
106+
flagext.DeprecatedFlag(f, "querier.query-store-for-labels-enabled", "Deprecated: Querying long-term store is always enabled.", util_log.Logger)
106107

107108
cfg.StoreGatewayClient.RegisterFlagsWithPrefix("querier.store-gateway-client", f)
108109
f.IntVar(&cfg.MaxConcurrent, "querier.max-concurrent", 20, "The maximum number of concurrent queries.")
109110
f.DurationVar(&cfg.Timeout, "querier.timeout", 2*time.Minute, "The timeout for a query.")
110111
f.BoolVar(&cfg.IngesterMetadataStreaming, "querier.ingester-metadata-streaming", false, "Use streaming RPCs for metadata APIs from ingester.")
111112
f.IntVar(&cfg.MaxSamples, "querier.max-samples", 50e6, "Maximum number of samples a single query can load into memory.")
112113
f.DurationVar(&cfg.QueryIngestersWithin, "querier.query-ingesters-within", 0, "Maximum lookback beyond which queries are not sent to ingester. 0 means all queries are sent to ingester.")
113-
f.BoolVar(&cfg.QueryStoreForLabels, "querier.query-store-for-labels-enabled", false, "Deprecated (Querying long-term store for labels will be always enabled in the future.): Query long-term store for series, label values and label names APIs.")
114114
f.BoolVar(&cfg.EnablePerStepStats, "querier.per-step-stats-enabled", false, "Enable returning samples stats per steps in query response.")
115115
f.DurationVar(&cfg.MaxQueryIntoFuture, "querier.max-query-into-future", 10*time.Minute, "Maximum duration into the future you can query. 0 to disable.")
116116
f.DurationVar(&cfg.DefaultEvaluationInterval, "querier.default-evaluation-interval", time.Minute, "The default evaluation interval or step size for subqueries.")
@@ -159,7 +159,7 @@ func getChunksIteratorFunction(_ Config) chunkIteratorFunc {
159159
func New(cfg Config, limits *validation.Overrides, distributor Distributor, stores []QueryableWithFilter, reg prometheus.Registerer, logger log.Logger) (storage.SampleAndChunkQueryable, storage.ExemplarQueryable, promql.QueryEngine) {
160160
iteratorFunc := getChunksIteratorFunction(cfg)
161161

162-
distributorQueryable := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, iteratorFunc, cfg.QueryIngestersWithin, cfg.QueryStoreForLabels)
162+
distributorQueryable := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, iteratorFunc, cfg.QueryIngestersWithin)
163163

164164
ns := make([]QueryableWithFilter, len(stores))
165165
for ix, s := range stores {
@@ -261,7 +261,6 @@ func NewQueryable(distributor QueryableWithFilter, stores []QueryableWithFilter,
261261
chunkIterFn: chunkIterFn,
262262
limits: limits,
263263
maxQueryIntoFuture: cfg.MaxQueryIntoFuture,
264-
queryStoreForLabels: cfg.QueryStoreForLabels,
265264
ignoreMaxQueryLength: cfg.IgnoreMaxQueryLength,
266265
distributor: distributor,
267266
stores: stores,
@@ -277,12 +276,11 @@ type querier struct {
277276
now time.Time
278277
mint, maxt int64
279278

280-
limits *validation.Overrides
281-
maxQueryIntoFuture time.Duration
282-
queryStoreForLabels bool
283-
distributor QueryableWithFilter
284-
stores []QueryableWithFilter
285-
limiterHolder *limiterHolder
279+
limits *validation.Overrides
280+
maxQueryIntoFuture time.Duration
281+
distributor QueryableWithFilter
282+
stores []QueryableWithFilter
283+
limiterHolder *limiterHolder
286284

287285
ignoreMaxQueryLength bool
288286
}
@@ -361,15 +359,6 @@ func (q querier) Select(ctx context.Context, sortSeries bool, sp *storage.Select
361359
}
362360
// if SelectHints is null, rely on minT, maxT of querier to scope in range for Select stmt
363361
sp = &storage.SelectHints{Start: mint, End: maxt}
364-
} else if sp.Func == "series" && !q.queryStoreForLabels {
365-
// Else if the querier receives a 'series' query, it means only metadata is needed.
366-
// Here we expect that metadataQuerier querier will handle that.
367-
// Also, in the recent versions of Prometheus, we pass in the hint but with Func set to "series".
368-
// See: https://github.com/prometheus/prometheus/pull/8050
369-
370-
// In this case, the query time range has already been validated when the querier has been
371-
// created.
372-
return metadataQuerier.Select(ctx, true, sp, matchers...)
373362
}
374363

375364
// Validate query time range. Even if the time range has already been validated when we created
@@ -433,7 +422,7 @@ func (q querier) Select(ctx context.Context, sortSeries bool, sp *storage.Select
433422

434423
// LabelValues implements storage.Querier.
435424
func (q querier) LabelValues(ctx context.Context, name string, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
436-
ctx, stats, _, _, _, metadataQuerier, queriers, err := q.setupFromCtx(ctx)
425+
ctx, stats, _, _, _, _, queriers, err := q.setupFromCtx(ctx)
437426
if err == errEmptyTimeRange {
438427
return nil, nil, nil
439428
} else if err != nil {
@@ -444,10 +433,6 @@ func (q querier) LabelValues(ctx context.Context, name string, matchers ...*labe
444433
stats.AddQueryStorageWallTime(time.Since(startT))
445434
}()
446435

447-
if !q.queryStoreForLabels {
448-
return metadataQuerier.LabelValues(ctx, name, matchers...)
449-
}
450-
451436
if len(queriers) == 1 {
452437
return queriers[0].LabelValues(ctx, name, matchers...)
453438
}
@@ -487,7 +472,7 @@ func (q querier) LabelValues(ctx context.Context, name string, matchers ...*labe
487472
}
488473

489474
func (q querier) LabelNames(ctx context.Context, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
490-
ctx, stats, _, _, _, metadataQuerier, queriers, err := q.setupFromCtx(ctx)
475+
ctx, stats, _, _, _, _, queriers, err := q.setupFromCtx(ctx)
491476
if err == errEmptyTimeRange {
492477
return nil, nil, nil
493478
} else if err != nil {
@@ -498,10 +483,6 @@ func (q querier) LabelNames(ctx context.Context, matchers ...*labels.Matcher) ([
498483
stats.AddQueryStorageWallTime(time.Since(startT))
499484
}()
500485

501-
if !q.queryStoreForLabels {
502-
return metadataQuerier.LabelNames(ctx, matchers...)
503-
}
504-
505486
if len(queriers) == 1 {
506487
return queriers[0].LabelNames(ctx, matchers...)
507488
}

pkg/querier/querier_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func TestShouldSortSeriesIfQueryingMultipleQueryables(t *testing.T) {
190190
}
191191

192192
distributor.On("QueryStream", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&unorderedResponse, nil)
193-
distributorQueryable := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, batch.NewChunkMergeIterator, cfg.QueryIngestersWithin, cfg.QueryStoreForLabels)
193+
distributorQueryable := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, batch.NewChunkMergeIterator, cfg.QueryIngestersWithin)
194194

195195
tCases := []struct {
196196
name string
@@ -363,7 +363,7 @@ func TestLimits(t *testing.T) {
363363
response: &streamResponse,
364364
}
365365

366-
distributorQueryableStreaming := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, batch.NewChunkMergeIterator, cfg.QueryIngestersWithin, cfg.QueryStoreForLabels)
366+
distributorQueryableStreaming := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, batch.NewChunkMergeIterator, cfg.QueryIngestersWithin)
367367

368368
tCases := []struct {
369369
name string

0 commit comments

Comments
 (0)