diff --git a/pkg/frontend/transport/handler.go b/pkg/frontend/transport/handler.go index bba985ea1c0..1ff113ac947 100644 --- a/pkg/frontend/transport/handler.go +++ b/pkg/frontend/transport/handler.go @@ -440,6 +440,7 @@ func (f *Handler) reportQueryStats(r *http.Request, source, userID string, query numStoreGatewayTouchedPostings := stats.LoadStoreGatewayTouchedPostings() numStoreGatewayTouchedPostingBytes := stats.LoadStoreGatewayTouchedPostingBytes() splitQueries := stats.LoadSplitQueries() + queryQueuedTime := stats.LoadQueuedTime() dataSelectMaxTime := stats.LoadDataSelectMaxTime() dataSelectMinTime := stats.LoadDataSelectMinTime() splitInterval := stats.LoadSplitInterval() @@ -471,6 +472,7 @@ func (f *Handler) reportQueryStats(r *http.Request, source, userID string, query "path", r.URL.Path, "response_time", queryResponseTime, "query_wall_time_seconds", wallTime.Seconds(), + "queue_time_seconds", queryQueuedTime.Seconds(), "response_series_count", numResponseSeries, "fetched_series_count", numFetchedSeries, "fetched_chunks_count", numFetchedChunks, @@ -634,6 +636,7 @@ func writeServiceTimingHeader(queryResponseTime time.Duration, headers http.Head if stats != nil { parts := make([]string, 0) parts = append(parts, statsValue("querier_wall_time", stats.LoadWallTime())) + parts = append(parts, statsValue("queue_time", stats.LoadQueuedTime())) parts = append(parts, statsValue("response_time", queryResponseTime)) headers.Set(ServiceTimingHeaderName, strings.Join(parts, ", ")) } diff --git a/pkg/frontend/transport/handler_test.go b/pkg/frontend/transport/handler_test.go index aa863230295..bc31074b780 100644 --- a/pkg/frontend/transport/handler_test.go +++ b/pkg/frontend/transport/handler_test.go @@ -471,12 +471,12 @@ func TestReportQueryStatsFormat(t *testing.T) { tests := map[string]testCase{ "should not include query and header details if empty": { - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 queue_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0`, source: tripperware.SourceAPI, }, "should include query length and string at the end": { queryString: url.Values(map[string][]string{"query": {"up"}}), - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 query_length=2 param_query=up`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 queue_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 query_length=2 param_query=up`, source: tripperware.SourceAPI, }, "should include query stats": { @@ -493,17 +493,17 @@ func TestReportQueryStatsFormat(t *testing.T) { SplitQueries: 10, }, }, - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=3 response_series_count=100 fetched_series_count=100 fetched_chunks_count=200 fetched_samples_count=300 fetched_chunks_bytes=1024 fetched_data_bytes=2048 split_queries=10 status_code=200 response_size=1000 samples_scanned=0 query_storage_wall_time_seconds=6000`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=3 queue_time_seconds=0 response_series_count=100 fetched_series_count=100 fetched_chunks_count=200 fetched_samples_count=300 fetched_chunks_bytes=1024 fetched_data_bytes=2048 split_queries=10 status_code=200 response_size=1000 samples_scanned=0 query_storage_wall_time_seconds=6000`, source: tripperware.SourceAPI, }, "should include user agent": { header: http.Header{"User-Agent": []string{"Grafana"}}, - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 user_agent=Grafana`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 queue_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 user_agent=Grafana`, source: tripperware.SourceAPI, }, "should include response error": { responseErr: errors.New("foo_err"), - expectedLog: `level=error msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 error=foo_err`, + expectedLog: `level=error msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 queue_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 error=foo_err`, source: tripperware.SourceAPI, }, "should include query priority": { @@ -512,7 +512,7 @@ func TestReportQueryStatsFormat(t *testing.T) { Priority: 99, PriorityAssigned: true, }, - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 query_length=2 priority=99 param_query=up`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 queue_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 query_length=2 priority=99 param_query=up`, source: tripperware.SourceAPI, }, "should include data fetch min and max time": { @@ -521,7 +521,7 @@ func TestReportQueryStatsFormat(t *testing.T) { DataSelectMaxTime: 1704153600000, DataSelectMinTime: 1704067200000, }, - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 data_select_max_time=1704153600 data_select_min_time=1704067200 query_length=2 param_query=up`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 queue_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0 data_select_max_time=1704153600 data_select_min_time=1704067200 query_length=2 param_query=up`, source: tripperware.SourceAPI, }, "should include query stats with store gateway stats": { @@ -540,7 +540,7 @@ func TestReportQueryStatsFormat(t *testing.T) { StoreGatewayTouchedPostingBytes: 200, }, }, - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=3 response_series_count=100 fetched_series_count=100 fetched_chunks_count=200 fetched_samples_count=300 fetched_chunks_bytes=1024 fetched_data_bytes=2048 split_queries=10 status_code=200 response_size=1000 samples_scanned=0 store_gateway_touched_postings_count=20 store_gateway_touched_posting_bytes=200 query_storage_wall_time_seconds=6000`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=3 queue_time_seconds=0 response_series_count=100 fetched_series_count=100 fetched_chunks_count=200 fetched_samples_count=300 fetched_chunks_bytes=1024 fetched_data_bytes=2048 split_queries=10 status_code=200 response_size=1000 samples_scanned=0 store_gateway_touched_postings_count=20 store_gateway_touched_posting_bytes=200 query_storage_wall_time_seconds=6000`, source: tripperware.SourceAPI, }, "should not report a log": { @@ -549,7 +549,7 @@ func TestReportQueryStatsFormat(t *testing.T) { enabledRulerQueryStatsLog: false, }, "should report a log": { - expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0`, + expectedLog: `level=info msg="query stats" component=query-frontend method=GET path=/prometheus/api/v1/query response_time=1s query_wall_time_seconds=0 queue_time_seconds=0 response_series_count=0 fetched_series_count=0 fetched_chunks_count=0 fetched_samples_count=0 fetched_chunks_bytes=0 fetched_data_bytes=0 split_queries=0 status_code=200 response_size=1000 samples_scanned=0`, source: tripperware.SourceRuler, enabledRulerQueryStatsLog: true, }, diff --git a/pkg/querier/stats/stats.go b/pkg/querier/stats/stats.go index 127c422878a..d97795be642 100644 --- a/pkg/querier/stats/stats.go +++ b/pkg/querier/stats/stats.go @@ -59,6 +59,32 @@ func (s *QueryStats) Copy() *QueryStats { return copied } +// AddQueuedTime adds some time to the queued time counter. +func (s *QueryStats) AddQueuedTime(t time.Duration) { + if s == nil { + return + } + + for { + cur := atomic.LoadInt64((*int64)(&s.QueuedTime)) + if int64(t) <= cur { + return + } + if atomic.CompareAndSwapInt64((*int64)(&s.QueuedTime), cur, int64(t)) { + return + } + } +} + +// LoadQueuedTime returns queued time. +func (s *QueryStats) LoadQueuedTime() time.Duration { + if s == nil { + return 0 + } + + return time.Duration(atomic.LoadInt64((*int64)(&s.QueuedTime))) +} + // AddWallTime adds some time to the counter. func (s *QueryStats) AddWallTime(t time.Duration) { if s == nil { @@ -395,6 +421,7 @@ func (s *QueryStats) Merge(other *QueryStats) { s.AddStoreGatewayTouchedPostingBytes(other.LoadStoreGatewayTouchedPostingBytes()) s.AddScannedSamples(other.LoadScannedSamples()) s.SetPeakSamples(max(s.LoadPeakSamples(), other.LoadPeakSamples())) + s.AddQueuedTime(other.LoadQueuedTime()) s.AddExtraFields(other.LoadExtraFields()...) } diff --git a/pkg/querier/stats/stats.pb.go b/pkg/querier/stats/stats.pb.go index ea6f4ba4185..96c40df08c9 100644 --- a/pkg/querier/stats/stats.pb.go +++ b/pkg/querier/stats/stats.pb.go @@ -65,6 +65,8 @@ type Stats struct { // The highest count of samples considered while evaluating a query. // Equal to PeakSamples in https://github.com/prometheus/prometheus/blob/main/util/stats/query_stats.go PeakSamples uint64 `protobuf:"varint,14,opt,name=peak_samples,json=peakSamples,proto3" json:"peak_samples,omitempty"` + // The time spent waiting in queue before being processed. + QueuedTime time.Duration `protobuf:"bytes,15,opt,name=queued_time,json=queuedTime,proto3,stdduration" json:"queued_time"` } func (m *Stats) Reset() { *m = Stats{} } @@ -197,6 +199,13 @@ func (m *Stats) GetPeakSamples() uint64 { return 0 } +func (m *Stats) GetQueuedTime() time.Duration { + if m != nil { + return m.QueuedTime + } + return 0 +} + func init() { proto.RegisterType((*Stats)(nil), "stats.Stats") proto.RegisterMapType((map[string]string)(nil), "stats.Stats.ExtraFieldsEntry") @@ -205,43 +214,44 @@ func init() { func init() { proto.RegisterFile("stats.proto", fileDescriptor_b4756a0aec8b9d44) } var fileDescriptor_b4756a0aec8b9d44 = []byte{ - // 574 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcf, 0x6e, 0xd3, 0x30, - 0x18, 0x8f, 0xb7, 0x75,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ff, 0xff, 0xd3, 0x67, 0xda, 0xe5, 0xfc, 0x03, 0x00, 0x00, + // 592 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x3d, 0x6f, 0xd3, 0x40, + 0x18, 0xf6, 0xb5, 0x4d, 0x5b, 0x9f, 0xd3, 0x0f, 0x4c, 0x10, 0x6e, 0x25, 0xae, 0x29, 0x45, 0x22, + 0x03, 0x72, 0x50, 0x58, 0x10, 0x48, 0xa8, 0x4a, 0x53, 0x60, 0x40, 0x08, 0x92, 0x4a, 0x48, 0x5d, + 0x4e, 0x97, 0xe4, 0xe2, 0x58, 0x71, 0xec, 0xd4, 0x3e, 0x53, 0xbc, 0xf1, 0x13, 0x58, 0x90, 0xf8, + 0x09, 0xfc, 0x94, 0x8c, 0x19, 0x3b, 0x15, 0xe2, 0x2c, 0x8c, 0xfd, 0x09, 0xe8, 0xde, 0xb3, 0x13, + 0xa8, 0x04, 0xea, 0xe6, 0x7b, 0x9f, 0x0f, 0xdd, 0xf3, 0xbc, 0xb9, 0x60, 0x23, 0x12, 0x4c, 0x44, + 0xf6, 0x28, 0x0c, 0x44, 0x60, 0x16, 0xe0, 0xb0, 0x5b, 0x72, 0x02, 0x27, 0x80, 0x49, 0x55, 0x7e, + 0x29, 0x70, 0x97, 0x38, 0x41, 0xe0, 0x78, 0xbc, 0x0a, 0xa7, 0x76, 0xdc, 0xab, 0x76, 0xe3, 0x90, + 0x09, 0x37, 0xf0, 0x33, 0x7c, 0xe7, 0x3a, 0xce, 0xfc, 0x44, 0x41, 0xf7, 0xbf, 0xae, 0xe1, 0x42, + 0x4b, 0x5a, 0x9b, 0x87, 0x58, 0x3f, 0x67, 0x9e, 0x47, 0x85, 0x3b, 0xe4, 0x16, 0x2a, 0xa3, 0x8a, + 0x51, 0xdb, 0xb1, 0x95, 0xd0, 0xce, 0x85, 0x76, 0x23, 0x33, 0xae, 0xaf,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d5, 0x94, 0xa0, 0xcf, 0x29, 0x41, 0xdf, 0x53, + 0x82, 0xc6, 0x29, 0x41, 0x93, 0x94, 0xa0, 0x9f, 0x29, 0x41, 0xbf, 0x52, 0xa2, 0x5d, 0xa5, 0x04, + 0x7d, 0x99, 0x11, 0x6d, 0x32, 0x23, 0xda, 0xc5, 0x8c, 0x68, 0xa7, 0xea, 0x5f, 0xa2, 0xbd, 0x0a, + 0xb7, 0x7c, 0xf2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x2d, 0xb2, 0x9d, 0x42, 0x04, 0x00, 0x00, } func (this *Stats) Equal(that interface{}) bool { @@ -310,13 +320,16 @@ func (this *Stats) Equal(that interface{}) bool { if this.PeakSamples != that1.PeakSamples { return false } + if this.QueuedTime != that1.QueuedTime { + return false + } return true } func (this *Stats) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 18) + s := make([]string, 0, 19) s = append(s, "&stats.Stats{") s = append(s, "WallTime: "+fmt.Sprintf("%#v", this.WallTime)+",\n") s = append(s, "FetchedSeriesCount: "+fmt.Sprintf("%#v", this.FetchedSeriesCount)+",\n") @@ -344,6 +357,7 @@ func (this *Stats) GoString() string { s = append(s, "StoreGatewayTouchedPostingBytes: "+fmt.Sprintf("%#v", this.StoreGatewayTouchedPostingBytes)+",\n") s = append(s, "ScannedSamples: "+fmt.Sprintf("%#v", this.ScannedSamples)+",\n") s = append(s, "PeakSamples: "+fmt.Sprintf("%#v", this.PeakSamples)+",\n") + s = append(s, "QueuedTime: "+fmt.Sprintf("%#v", this.QueuedTime)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -375,6 +389,14 @@ func (m *Stats) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.QueuedTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.QueuedTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintStats(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x7a if m.PeakSamples != 0 { i = encodeVarintStats(dAtA, i, uint64(m.PeakSamples)) i-- @@ -395,12 +417,12 @@ func (m *Stats) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x58 } - n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.QueryStorageWallTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.QueryStorageWallTime):]) - if err1 != nil { - return 0, err1 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.QueryStorageWallTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.QueryStorageWallTime):]) + if err2 != nil { + return 0, err2 } - i -= n1 - i = encodeVarintStats(dAtA, i, uint64(n1)) + i -= n2 + i = encodeVarintStats(dAtA, i, uint64(n2)) i-- dAtA[i] = 0x52 if m.SplitQueries != 0 { @@ -459,12 +481,12 @@ func (m *Stats) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.WallTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.WallTime):]) - if err2 != nil { - return 0, err2 + n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.WallTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.WallTime):]) + if err3 != nil { + return 0, err3 } - i -= n2 - i = encodeVarintStats(dAtA, i, uint64(n2)) + i -= n3 + i = encodeVarintStats(dAtA, i, uint64(n3)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -533,6 +555,8 @@ func (m *Stats) Size() (n int) { if m.PeakSamples != 0 { n += 1 + sovStats(uint64(m.PeakSamples)) } + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.QueuedTime) + n += 1 + l + sovStats(uint64(l)) return n } @@ -571,6 +595,7 @@ func (this *Stats) String() string { `StoreGatewayTouchedPostingBytes:` + fmt.Sprintf("%v", this.StoreGatewayTouchedPostingBytes) + `,`, `ScannedSamples:` + fmt.Sprintf("%v", this.ScannedSamples) + `,`, `PeakSamples:` + fmt.Sprintf("%v", this.PeakSamples) + `,`, + `QueuedTime:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.QueuedTime), "Duration", "duration.Duration", 1), `&`, ``, 1) + `,`, `}`, }, "") return s @@ -1027,6 +1052,39 @@ func (m *Stats) Unmarshal(dAtA []byte) error { break } } + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QueuedTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStats + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStats + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStats + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.QueuedTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStats(dAtA[iNdEx:]) diff --git a/pkg/querier/stats/stats.proto b/pkg/querier/stats/stats.proto index 8e53e02ccc3..f8bed674969 100644 --- a/pkg/querier/stats/stats.proto +++ b/pkg/querier/stats/stats.proto @@ -45,4 +45,6 @@ message Stats { // The highest count of samples considered while evaluating a query. // Equal to PeakSamples in https://github.com/prometheus/prometheus/blob/main/util/stats/query_stats.go uint64 peak_samples = 14; + // The time spent waiting in queue before being processed. + google.protobuf.Duration queued_time = 15 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; } diff --git a/pkg/querier/worker/scheduler_processor.go b/pkg/querier/worker/scheduler_processor.go index 10fd96ab230..1b146f996b9 100644 --- a/pkg/querier/worker/scheduler_processor.go +++ b/pkg/querier/worker/scheduler_processor.go @@ -141,6 +141,11 @@ func (sp *schedulerProcessor) querierLoop(c schedulerpb.SchedulerForQuerier_Quer for _, h := range request.HttpRequest.Headers { headers[h.Key] = h.Values[0] } + if request.StatsEnabled { + if qs := querier_stats.FromContext(ctx); qs != nil { + qs.AddQueuedTime(time.Duration(request.QueuedTime)) + } + } ctx = requestmeta.ContextWithRequestMetadataMapFromHeaders(ctx, headers, sp.targetHeaders) tracer := opentracing.GlobalTracer() diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go index 7c7ef4b7b3e..887daf8fddf 100644 --- a/pkg/scheduler/scheduler.go +++ b/pkg/scheduler/scheduler.go @@ -159,6 +159,7 @@ type schedulerRequest struct { statsEnabled bool enqueueTime time.Time + queuedTime time.Duration ctx context.Context ctxCancel context.CancelFunc @@ -376,8 +377,10 @@ func (s *Scheduler) QuerierLoop(querier schedulerpb.SchedulerForQuerier_QuerierL r := req.(*schedulerRequest) - s.queueDuration.Observe(time.Since(r.enqueueTime).Seconds()) + queuedTime := time.Since(r.enqueueTime) + s.queueDuration.Observe(queuedTime.Seconds()) r.queueSpan.Finish() + r.queuedTime = queuedTime /* We want to dequeue the next unexpired request from the chosen tenant queue. @@ -428,6 +431,7 @@ func (s *Scheduler) forwardRequestToQuerier(querier schedulerpb.SchedulerForQuer FrontendAddress: req.frontendAddress, HttpRequest: req.request, StatsEnabled: req.statsEnabled, + QueuedTime: int64(req.queuedTime), }) if err != nil { errCh <- err diff --git a/pkg/scheduler/schedulerpb/scheduler.pb.go b/pkg/scheduler/schedulerpb/scheduler.pb.go index d3288f95b39..79387c8d6d7 100644 --- a/pkg/scheduler/schedulerpb/scheduler.pb.go +++ b/pkg/scheduler/schedulerpb/scheduler.pb.go @@ -139,6 +139,8 @@ type SchedulerToQuerier struct { // Whether query statistics tracking should be enabled. The response will include // statistics only when this option is enabled. StatsEnabled bool `protobuf:"varint,5,opt,name=statsEnabled,proto3" json:"statsEnabled,omitempty"` + // Time in nanoseconds the request spent in the scheduler queue. + QueuedTime int64 `protobuf:"varint,6,opt,name=queuedTime,proto3" json:"queuedTime,omitempty"` } func (m *SchedulerToQuerier) Reset() { *m = SchedulerToQuerier{} } @@ -208,6 +210,13 @@ func (m *SchedulerToQuerier) GetStatsEnabled() bool { return false } +func (m *SchedulerToQuerier) GetQueuedTime() int64 { + if m != nil { + return m.QueuedTime + } + return 0 +} + type FrontendToScheduler struct { Type FrontendToSchedulerType `protobuf:"varint,1,opt,name=type,proto3,enum=schedulerpb.FrontendToSchedulerType" json:"type,omitempty"` // Used by INIT message. Will be put into all requests passed to querier. @@ -438,48 +447,49 @@ func init() { func init() { proto.RegisterFile("scheduler.proto", fileDescriptor_2b3fc28395a6d9c5) } var fileDescriptor_2b3fc28395a6d9c5 = []byte{ - // 644 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4f, 0x4f, 0xdb, 0x4e, - 0x10, 0xf5, 0x86, 0x24, 0xc0, 0x84, 0xdf, 0x0f, 0x77, 0x81, 0x36, 0x8d, 0xe8, 0x12, 0x45, 0x55, - 0x95, 0x72, 0x48, 0xaa, 0xb4, 0x52, 0x7b, 0x40, 0x95, 0x52, 0x30, 0x25, 0x2a, 0x75, 0x60, 0xb3, - 0x51, 0xff, 0x5c, 0x22, 0x92, 0x2c, 0x09, 0x02, 0xbc, 0x66, 0x6d, 0x17, 0xe5, 0xd6, 0x63, 0x8f, - 0xfd, 0x18, 0xfd, 0x28, 0xbd, 0x54, 0xe2, 0xc8, 0xa1, 0x87, 0x62, 0x2e, 0x3d, 0xf2, 0x11, 0xaa, - 0x38, 0x76, 0xea, 0xa4, 0x0e, 0x70, 0x9b, 0x1d, 0xbf, 0xe7, 0x9d, 0xf7, 0x66, 0x66, 0x61, 0xde, - 0x6a, 0x75, 0x79, 0xdb, 0x39, 0xe2, 0xb2, 0x60, 0x4a, 0x61, 0x0b, 0x9c, 0x1a, 0x26, 0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, 0x9d, 0xa9, 0x08, 0xcf, 0x42, - 0x42, 0xa3, 0xb4, 0x4a, 0xd5, 0x18, 0xbe, 0x03, 0xff, 0xd5, 0xb6, 0xea, 0x8c, 0x55, 0xf4, 0xd7, - 0x8d, 0x8d, 0xea, 0x3b, 0x5d, 0x9d, 0x2a, 0xfd, 0x44, 0x21, 0xbf, 0x37, 0x85, 0x0c, 0x56, 0xa9, - 0x0e, 0x29, 0x3f, 0xdc, 0x16, 0xc2, 0xc4, 0x2b, 0x23, 0x76, 0xff, 0xbb, 0xaf, 0x99, 0x95, 0x49, - 0xfd, 0xf0, 0xb1, 0x39, 0x25, 0x8f, 0x9e, 0x20, 0x6c, 0xc0, 0x52, 0xa4, 0x65, 0xf8, 0xf1, 0x08, - 0xff, 0xba, 0xa6, 0x64, 0x56, 0x6f, 0x03, 0x1d, 0x74, 0xa0, 0x64, 0xc2, 0x62, 0x58, 0xdd, 0x70, - 0x9c, 0xde, 0xc3, 0x5c, 0x10, 0x7b, 0xfa, 0xb2, 0x37, 0xad, 0x56, 0x26, 0x7b, 0xd3, 0xc0, 0x0d, - 0x14, 0xbe, 0x2a, 0x9f, 0x5d, 0x10, 0xe5, 0xfc, 0x82, 0x28, 0x57, 0x17, 0x04, 0x7d, 0x76, 0x09, - 0xfa, 0xe6, 0x12, 0xf4, 0xdd, 0x25, 0xe8, 0xcc, 0x25, 0xe8, 0x97, 0x4b, 0xd0, 0x6f, 0x97, 0x28, - 0x57, 0x2e, 0x41, 0x5f, 0x2f, 0x89, 0x72, 0x76, 0x49, 0x94, 0xf3, 0x4b, 0xa2, 0x7c, 0x0c, 0xbf, - 0xae, 0xcd, 0xa4, 0xf7, 0x30, 0x3e, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x88, 0x0c, 0xfe, 0x56, - 0x84, 0x05, 0x00, 0x00, + // 660 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 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0x8e, 0xe8, + 0xaf, 0x1b, 0x4a, 0x66, 0xed, 0x36, 0xd4, 0xfe, 0x04, 0x0a, 0x16, 0x2c, 0x45, 0xdd, 0x0d, 0xd7, + 0xe9, 0x23, 0xcc, 0x0f, 0xea, 0xc0, 0x9f, 0x7c, 0xd3, 0xd3, 0xca, 0xc8, 0x37, 0x2d, 0x5c, 0xdf, + 0xe1, 0x9b, 0xe2, 0xe9, 0x39, 0x11, 0xce, 0xce, 0x89, 0x70, 0x79, 0x4e, 0xd0, 0x57, 0x9f, 0xa0, + 0x1f, 0x3e, 0x41, 0x3f, 0x7d, 0x82, 0x4e, 0x7d, 0x82, 0x7e, 0xfb, 0x04, 0xfd, 0xf1, 0x89, 0x70, + 0xe9, 0x13, 0xf4, 0xfd, 0x82, 0x08, 0xa7, 0x17, 0x44, 0x38, 0xbb, 0x20, 0xc2, 0xe7, 0xe8, 0xdf, + 0xb7, 0x2e, 0x06, 0x3f, 0xce, 0xe7, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x1f, 0x4e, 0x90, + 0xa4, 0x05, 0x00, 0x00, } func (x FrontendToSchedulerType) String() string { @@ -554,6 +564,9 @@ func (this *SchedulerToQuerier) Equal(that interface{}) bool { if this.StatsEnabled != that1.StatsEnabled { return false } + if this.QueuedTime != that1.QueuedTime { + return false + } return true } func (this *FrontendToScheduler) Equal(that interface{}) bool { @@ -681,7 +694,7 @@ func (this *SchedulerToQuerier) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 9) + s := make([]string, 0, 10) s = append(s, "&schedulerpb.SchedulerToQuerier{") s = append(s, "QueryID: "+fmt.Sprintf("%#v", this.QueryID)+",\n") if this.HttpRequest != nil { @@ -690,6 +703,7 @@ func (this *SchedulerToQuerier) GoString() string { s = append(s, "FrontendAddress: "+fmt.Sprintf("%#v", this.FrontendAddress)+",\n") s = append(s, "UserID: "+fmt.Sprintf("%#v", this.UserID)+",\n") s = append(s, "StatsEnabled: "+fmt.Sprintf("%#v", this.StatsEnabled)+",\n") + s = append(s, "QueuedTime: "+fmt.Sprintf("%#v", this.QueuedTime)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -1078,6 +1092,11 @@ func (m *SchedulerToQuerier) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.QueuedTime != 0 { + i = encodeVarintScheduler(dAtA, i, uint64(m.QueuedTime)) + i-- + dAtA[i] = 0x30 + } if m.StatsEnabled { i-- if m.StatsEnabled { @@ -1327,6 +1346,9 @@ func (m *SchedulerToQuerier) Size() (n int) { if m.StatsEnabled { n += 2 } + if m.QueuedTime != 0 { + n += 1 + sovScheduler(uint64(m.QueuedTime)) + } return n } @@ -1424,6 +1446,7 @@ func (this *SchedulerToQuerier) String() string { `FrontendAddress:` + fmt.Sprintf("%v", this.FrontendAddress) + `,`, `UserID:` + fmt.Sprintf("%v", this.UserID) + `,`, `StatsEnabled:` + fmt.Sprintf("%v", this.StatsEnabled) + `,`, + `QueuedTime:` + fmt.Sprintf("%v", this.QueuedTime) + `,`, `}`, }, "") return s @@ -1734,6 +1757,25 @@ func (m *SchedulerToQuerier) Unmarshal(dAtA []byte) error { } } m.StatsEnabled = bool(v != 0) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueuedTime", wireType) + } + m.QueuedTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowScheduler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueuedTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipScheduler(dAtA[iNdEx:]) diff --git a/pkg/scheduler/schedulerpb/scheduler.proto b/pkg/scheduler/schedulerpb/scheduler.proto index eea28717b83..a9497deb3c0 100644 --- a/pkg/scheduler/schedulerpb/scheduler.proto +++ b/pkg/scheduler/schedulerpb/scheduler.proto @@ -45,6 +45,9 @@ message SchedulerToQuerier { // Whether query statistics tracking should be enabled. The response will include // statistics only when this option is enabled. bool statsEnabled = 5; + + // Time in nanoseconds the request spent in the scheduler queue. + int64 queuedTime = 6; } // Scheduler interface exposed to Frontend. Frontend can enqueue and cancel requests.