Skip to content

Commit 745b808

Browse files
committed
Merge remote-tracking branch 'origin/master' into ingester_querying
2 parents 84e8fdf + 8cf2583 commit 745b808

Some content is hidden

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

54 files changed

+1703
-479
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
* [ENHANCEMENT] Querier: limit series query to only ingesters if `start` param is not specified. #4976
66
* [ENHANCEMENT] Query-frontend/scheduler: add a new limit `frontend.max-outstanding-requests-per-tenant` for configuring queue size per tenant. Started deprecating two flags `-query-scheduler.max-outstanding-requests-per-tenant` and `-querier.max-outstanding-requests-per-tenant`, and change their value default to 0. Now if both the old flag and new flag are specified, the old flag's queue size will be picked. #5005
77
* [ENHANCEMENT] Query-tee: Add `/api/v1/query_exemplars` API endpoint support. #5010
8+
* [ENHANCEMENT] Query Frontend/Query Scheduler: Increase upper bound to 60s for queue duration histogram metric. #5029
89
* [ENHANCEMENT] Ingester: The metadata APIs should honour `querier.query-ingesters-within` when `querier.query-store-for-labels-enabled` is true. #5027
910
* [FEATURE] Querier/Query Frontend: support Prometheus /api/v1/status/buildinfo API. #4978
1011
* [FEATURE] Ingester: Add active series to all_user_stats page. #4972
1112
* [FEATURE] Ingester: Added `-blocks-storage.tsdb.head-chunks-write-queue-size` allowing to configure the size of the in-memory queue used before flushing chunks to the disk . #5000
1213
* [FEATURE] Query Frontend: Log query params in query frontend even if error happens. #5005
1314
* [FEATURE] Ingester: Enable snapshotting of In-memory TSDB on disk during shutdown via `-blocks-storage.tsdb.memory-snapshot-on-shutdown`. #5011
15+
* [FEATURE] Query Frontend/Scheduler: Add a new counter metric `cortex_request_queue_requests_total` for total requests going to queue. #5030
1416
* [BUGFIX] Updated `golang.org/x/net` dependency to fix CVE-2022-27664. #5008
1517

1618
## 1.14.0 2022-12-02

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ require (
3030
github.com/hashicorp/go-sockaddr v1.0.2
3131
github.com/hashicorp/memberlist v0.5.0
3232
github.com/json-iterator/go v1.1.12
33-
github.com/lib/pq v1.3.0
33+
github.com/lib/pq v1.10.7
3434
github.com/minio/minio-go/v7 v7.0.37
35-
github.com/mitchellh/go-wordwrap v1.0.0
35+
github.com/mitchellh/go-wordwrap v1.0.1
3636
github.com/oklog/ulid v1.3.1
3737
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e
3838
github.com/opentracing-contrib/go-stdlib v1.0.0
@@ -45,8 +45,8 @@ require (
4545
github.com/prometheus/prometheus v0.39.1
4646
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
4747
github.com/sony/gobreaker v0.5.0
48-
github.com/spf13/afero v1.6.0
49-
github.com/stretchr/testify v1.8.0
48+
github.com/spf13/afero v1.9.3
49+
github.com/stretchr/testify v1.8.1
5050
github.com/thanos-io/objstore v0.0.0-20221006135717-79dcec7fe604
5151
github.com/thanos-io/thanos v0.29.1-0.20221115064008-fe45cfc66b7d
5252
github.com/uber/jaeger-client-go v2.30.0+incompatible
@@ -180,7 +180,7 @@ require (
180180
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
181181
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect
182182
github.com/sirupsen/logrus v1.9.0 // indirect
183-
github.com/stretchr/objx v0.4.0 // indirect
183+
github.com/stretchr/objx v0.5.0 // indirect
184184
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
185185
github.com/vimeo/galaxycache v0.0.0-20210323154928-b7e5d71c067a // indirect
186186
github.com/weaveworks/promrus v1.2.0 // indirect

go.sum

Lines changed: 24 additions & 9 deletions
Large diffs are not rendered by default.

pkg/frontend/v1/frontend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ func New(cfg Config, limits Limits, log log.Logger, registerer prometheus.Regist
108108
queueDuration: promauto.With(registerer).NewHistogram(prometheus.HistogramOpts{
109109
Name: "cortex_query_frontend_queue_duration_seconds",
110110
Help: "Time spend by requests queued.",
111-
Buckets: prometheus.DefBuckets,
111+
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 20, 30, 60},
112112
}),
113113
}
114114

115-
f.requestQueue = queue.NewRequestQueue(cfg.MaxOutstandingPerTenant, cfg.QuerierForgetDelay, f.queueLength, f.discardedRequests, f.limits)
115+
f.requestQueue = queue.NewRequestQueue(cfg.MaxOutstandingPerTenant, cfg.QuerierForgetDelay, f.queueLength, f.discardedRequests, f.limits, registerer)
116116
f.activeUsers = util.NewActiveUsersCleanupWithDefaultValues(f.cleanupInactiveUserMetrics)
117117

118118
var err error

pkg/frontend/v1/frontend_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func TestFrontendCheckReady(t *testing.T) {
133133
prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user"}),
134134
prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"}),
135135
limits,
136+
nil,
136137
),
137138
}
138139
for i := 0; i < tt.connectedClients; i++ {

pkg/scheduler/queue/queue.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/pkg/errors"
99
"github.com/prometheus/client_golang/prometheus"
10+
"github.com/prometheus/client_golang/prometheus/promauto"
1011
"go.uber.org/atomic"
1112

1213
"github.com/cortexproject/cortex/pkg/util/services"
@@ -58,15 +59,20 @@ type RequestQueue struct {
5859
stopped bool
5960

6061
queueLength *prometheus.GaugeVec // Per user and reason.
62+
totalRequests *prometheus.CounterVec // Per user.
6163
discardedRequests *prometheus.CounterVec // Per user.
6264
}
6365

64-
func NewRequestQueue(maxOutstandingPerTenant int, forgetDelay time.Duration, queueLength *prometheus.GaugeVec, discardedRequests *prometheus.CounterVec, limits Limits) *RequestQueue {
66+
func NewRequestQueue(maxOutstandingPerTenant int, forgetDelay time.Duration, queueLength *prometheus.GaugeVec, discardedRequests *prometheus.CounterVec, limits Limits, registerer prometheus.Registerer) *RequestQueue {
6567
q := &RequestQueue{
6668
queues: newUserQueues(maxOutstandingPerTenant, forgetDelay, limits),
6769
connectedQuerierWorkers: atomic.NewInt32(0),
6870
queueLength: queueLength,
69-
discardedRequests: discardedRequests,
71+
totalRequests: promauto.With(registerer).NewCounterVec(prometheus.CounterOpts{
72+
Name: "cortex_request_queue_requests_total",
73+
Help: "Total number of query requests going to the request queue.",
74+
}, []string{"user"}),
75+
discardedRequests: discardedRequests,
7076
}
7177

7278
q.cond = sync.NewCond(&q.mtx)
@@ -94,6 +100,7 @@ func (q *RequestQueue) EnqueueRequest(userID string, req Request, maxQueriers in
94100
return errors.New("no queue found")
95101
}
96102

103+
q.totalRequests.WithLabelValues(userID).Inc()
97104
select {
98105
case queue <- req:
99106
q.queueLength.WithLabelValues(userID).Inc()

pkg/scheduler/queue/queue_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func BenchmarkGetNextRequest(b *testing.B) {
2727
prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user"}),
2828
prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"}),
2929
MockLimits{MaxOutstanding: 100},
30+
nil,
3031
)
3132
queues = append(queues, queue)
3233

@@ -85,6 +86,7 @@ func BenchmarkQueueRequest(b *testing.B) {
8586
prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user"}),
8687
prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"}),
8788
MockLimits{MaxOutstanding: 100},
89+
nil,
8890
)
8991

9092
for ix := 0; ix < queriers; ix++ {
@@ -119,6 +121,7 @@ func TestRequestQueue_GetNextRequestForQuerier_ShouldGetRequestAfterReshardingBe
119121
prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user"}),
120122
prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"}),
121123
MockLimits{MaxOutstanding: 100},
124+
nil,
122125
)
123126

124127
// Start the queue service.

pkg/scheduler/scheduler.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ func NewScheduler(cfg Config, limits Limits, log log.Logger, registerer promethe
111111
Name: "cortex_query_scheduler_discarded_requests_total",
112112
Help: "Total number of query requests discarded.",
113113
}, []string{"user"})
114-
s.requestQueue = queue.NewRequestQueue(cfg.MaxOutstandingPerTenant, cfg.QuerierForgetDelay, s.queueLength, s.discardedRequests, s.limits)
114+
115+
s.requestQueue = queue.NewRequestQueue(cfg.MaxOutstandingPerTenant, cfg.QuerierForgetDelay, s.queueLength, s.discardedRequests, s.limits, registerer)
115116

116117
s.queueDuration = promauto.With(registerer).NewHistogram(prometheus.HistogramOpts{
117118
Name: "cortex_query_scheduler_queue_duration_seconds",
118119
Help: "Time spend by requests in queue before getting picked up by a querier.",
119-
Buckets: prometheus.DefBuckets,
120+
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 20, 30, 60},
120121
})
121122
s.connectedQuerierClients = promauto.With(registerer).NewGaugeFunc(prometheus.GaugeOpts{
122123
Name: "cortex_query_scheduler_connected_querier_clients",

pkg/storage/tsdb/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ const (
2424
// set when shipping blocks to the storage.
2525
IngesterIDExternalLabel = "__ingester_id__"
2626

27-
// ShardIDExternalLabel is the external label containing the shard ID
28-
// and can be used to shard blocks.
29-
ShardIDExternalLabel = "__shard_id__"
30-
3127
// How often are open TSDBs checked for being idle and closed.
3228
DefaultCloseIdleTSDBInterval = 5 * time.Minute
3329

pkg/storegateway/bucket_stores.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ func (u *BucketStores) getOrCreateStore(userID string) (*store.BucketStore, erro
431431
NewReplicaLabelRemover(userLogger, []string{
432432
tsdb.TenantIDExternalLabel,
433433
tsdb.IngesterIDExternalLabel,
434-
tsdb.ShardIDExternalLabel,
435434
}),
436435
// Remove Cortex external labels so that they're not injected when querying blocks.
437436
}...)

0 commit comments

Comments
 (0)