Skip to content

Commit 78e6da8

Browse files
authored
Logging Vertical Sharding info on query stats (#5037)
* logging sharding stats Signed-off-by: Alan Protasio <[email protected]> * test Signed-off-by: Alan Protasio <[email protected]> * improving tests Signed-off-by: Alan Protasio <[email protected]> * changelog Signed-off-by: Alan Protasio <[email protected]> Signed-off-by: Alan Protasio <[email protected]>
1 parent b108121 commit 78e6da8

File tree

14 files changed

+443
-148
lines changed

14 files changed

+443
-148
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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
88
* [ENHANCEMENT] Query Frontend/Query Scheduler: Increase upper bound to 60s for queue duration histogram metric. #5029
9+
* [ENHANCEMENT] Query Frontend: Log Vertical sharding information when `query_stats_enabled` is enabled. #5037
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

pkg/frontend/transport/handler.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logge
112112

113113
func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
114114
var (
115-
stats *querier_stats.Stats
115+
stats *querier_stats.QueryStats
116116
queryString url.Values
117117
)
118118

@@ -185,7 +185,7 @@ func (f *Handler) reportSlowQuery(r *http.Request, queryString url.Values, query
185185
level.Info(util_log.WithContext(r.Context(), f.log)).Log(logMessage...)
186186
}
187187

188-
func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, queryResponseTime time.Duration, stats *querier_stats.Stats, error error) {
188+
func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, queryResponseTime time.Duration, stats *querier_stats.QueryStats, error error) {
189189
tenantIDs, err := tenant.TenantIDs(r.Context())
190190
if err != nil {
191191
return
@@ -214,7 +214,9 @@ func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, quer
214214
"fetched_series_count", numSeries,
215215
"fetched_chunks_bytes", numBytes,
216216
"fetched_data_bytes", numDataBytes,
217-
}, formatQueryString(queryString)...)
217+
}, stats.LoadExtraFields()...)
218+
219+
logMessage = append(logMessage, formatQueryString(queryString)...)
218220

219221
if error != nil {
220222
s, ok := status.FromError(error)
@@ -264,7 +266,7 @@ func writeError(w http.ResponseWriter, err error) {
264266
server.WriteError(w, err)
265267
}
266268

267-
func writeServiceTimingHeader(queryResponseTime time.Duration, headers http.Header, stats *querier_stats.Stats) {
269+
func writeServiceTimingHeader(queryResponseTime time.Duration, headers http.Header, stats *querier_stats.QueryStats) {
268270
if stats != nil {
269271
parts := make([]string, 0)
270272
parts = append(parts, statsValue("querier_wall_time", stats.LoadWallTime()))

pkg/frontend/v1/frontendv1pb/frontend.pb.go

Lines changed: 50 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/frontend/v1/frontendv1pb/frontend.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ message FrontendToClient {
3939
message ClientToFrontend {
4040
httpgrpc.HTTPResponse httpResponse = 1;
4141
string clientID = 2;
42-
stats.Stats stats = 3;
42+
stats.Stats stats = 3[(gogoproto.customtype) = "github.com/cortexproject/cortex/pkg/querier/stats.QueryStats"];
4343
}
4444

4545
message NotifyClientShutdownRequest {

pkg/frontend/v2/frontend_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func sendResponseWithDelay(f *Frontend, delay time.Duration, userID string, quer
8888
_, _ = f.QueryResult(ctx, &frontendv2pb.QueryResultRequest{
8989
QueryID: queryID,
9090
HttpResponse: resp,
91-
Stats: &stats.Stats{},
91+
Stats: &stats.QueryStats{},
9292
})
9393
}
9494

0 commit comments

Comments
 (0)