diff --git a/pkg/logql/metrics.go b/pkg/logql/metrics.go index f9b9d1a8f952b..d5a3f38a21f3b 100644 --- a/pkg/logql/metrics.go +++ b/pkg/logql/metrics.go @@ -189,6 +189,8 @@ func RecordRangeAndInstantQueryMetrics( "ingester_chunk_decompressed_bytes", humanizeBytes(uint64(stats.Ingester.Store.Chunk.GetDecompressedBytes())), // Total lines post filtering. "ingester_post_filter_lines", stats.Ingester.Store.Chunk.GetPostFilterLines(), + // Time spent being blocked on congestion control. + "congestion_control_latency", stats.CongestionControlLatency(), }...) logValues = append(logValues, tagsToKeyValues(queryTags)...) diff --git a/pkg/logqlmodel/stats/context.go b/pkg/logqlmodel/stats/context.go index 1271fa6d9c210..05426840015c3 100644 --- a/pkg/logqlmodel/stats/context.go +++ b/pkg/logqlmodel/stats/context.go @@ -96,6 +96,11 @@ func (c *Context) Ingester() Ingester { } } +// Querier returns the store statistics accumulated so far. +func (c *Context) Querier() Querier { + return c.querier +} + // Caches returns the cache statistics accumulated so far. func (c *Context) Caches() Caches { return Caches{ @@ -279,6 +284,10 @@ func (r Result) ChunkRefsFetchTime() time.Duration { return time.Duration(r.Querier.Store.ChunkRefsFetchTime + r.Ingester.Store.ChunkRefsFetchTime) } +func (r Result) CongestionControlLatency() time.Duration { + return time.Duration(r.Querier.Store.CongestionControlLatency) +} + func (r Result) TotalDuplicates() int64 { return r.Querier.Store.Chunk.TotalDuplicates + r.Ingester.Store.Chunk.TotalDuplicates } @@ -360,6 +369,10 @@ func (c *Context) AddChunkRefsFetchTime(i time.Duration) { atomic.AddInt64(&c.store.ChunkRefsFetchTime, int64(i)) } +func (c *Context) AddCongestionControlLatency(i time.Duration) { + atomic.AddInt64(&c.querier.Store.CongestionControlLatency, int64(i)) +} + func (c *Context) AddChunksDownloaded(i int64) { atomic.AddInt64(&c.store.TotalChunksDownloaded, i) } diff --git a/pkg/logqlmodel/stats/stats.pb.go b/pkg/logqlmodel/stats/stats.pb.go index 65f8f0f642381..f25143272599b 100644 --- a/pkg/logqlmodel/stats/stats.pb.go +++ b/pkg/logqlmodel/stats/stats.pb.go @@ -476,6 +476,8 @@ type Store struct { Chunk Chunk `protobuf:"bytes,4,opt,name=chunk,proto3" json:"chunk"` // Time spent fetching chunk refs from index. ChunkRefsFetchTime int64 `protobuf:"varint,5,opt,name=chunkRefsFetchTime,proto3" json:"chunkRefsFetchTime"` + // Time spent being blocked on congestion control. + CongestionControlLatency int64 `protobuf:"varint,6,opt,name=congestionControlLatency,proto3" json:"congestionControlLatency"` } func (m *Store) Reset() { *m = Store{} } @@ -552,6 +554,13 @@ func (m *Store) GetChunkRefsFetchTime() int64 { return 0 } +func (m *Store) GetCongestionControlLatency() int64 { + if m != nil { + return m.CongestionControlLatency + } + return 0 +} + type Chunk struct { // Total bytes processed but was already in memory (found in the headchunk). Includes structured metadata bytes. HeadChunkBytes int64 `protobuf:"varint,4,opt,name=headChunkBytes,proto3" json:"headChunkBytes"` @@ -781,85 +790,87 @@ func init() { func init() { proto.RegisterFile("pkg/logqlmodel/stats/stats.proto", fileDescriptor_6cdfe5d2aea33ebb) } var fileDescriptor_6cdfe5d2aea33ebb = []byte{ - // 1241 bytes of a gzipped FileDescriptorProto + // 1274 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0x4b, 0x6f, 0xe3, 0x54, - 0x14, 0x8e, 0x27, 0xe3, 0xa4, 0xbd, 0x7d, 0xce, 0x6d, 0x87, 0xc9, 0x30, 0x92, 0x5d, 0x02, 0x23, - 0x8a, 0x40, 0x8d, 0x78, 0x48, 0x08, 0xc4, 0x48, 0xc8, 0x1d, 0x2a, 0x55, 0x6a, 0x45, 0x39, 0x81, - 0x0d, 0xac, 0x1c, 0xfb, 0x36, 0xb1, 0xea, 0xd8, 0xa9, 0x7d, 0x5d, 0xa6, 0x2b, 0xf8, 0x09, 0xec, - 0xf9, 0x03, 0x6c, 0x58, 0xb1, 0x42, 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, 0xd4, 0x12, 0x0c, 0xfc, - 0x21, 0xd2, 0x9d, 0x51, 0x12, 0x9c, 0xc9, 0x3d, 0xaf, 0x96, 0xf5, 0x25, 0x39, 0xa3, 0x80, 0x78, - 0x30, 0x89, 0x17, 0xb8, 0xe4, 0x99, 0xdc, 0xeb, 0x02, 0x09, 0xa7, 0x80, 0x78, 0xb0, 0x65, 0x46, - 0xfc, 0x94, 0xe5, 0x1e, 0x55, 0xcd, 0xba, 0xd4, 0x48, 0x0e, 0xc8, 0x27, 0xde, 0x47, 0x2b, 0x9c, - 0x26, 0x5e, 0x90, 0xdc, 0xa1, 0x2a, 0xdd, 0x92, 0xd2, 0x32, 0x11, 0xca, 0x06, 0x3e, 0x40, 0xab, - 0x17, 0xa1, 0x9f, 0x8c, 0x89, 0x8c, 0xa2, 0xd7, 0x44, 0xd9, 0x96, 0x51, 0x14, 0x26, 0x28, 0x16, - 0x8b, 0x13, 0xb3, 0x57, 0x36, 0x5b, 0x4d, 0xeb, 0x55, 0x71, 0xca, 0x4c, 0x50, 0x2c, 0xb6, 0x29, - 0xdf, 0x1e, 0x10, 0x5f, 0x86, 0x69, 0xbf, 0x6a, 0x53, 0x25, 0x22, 0x94, 0x0d, 0xfc, 0x03, 0xda, - 0xf2, 0x82, 0x98, 0xda, 0x01, 0x3d, 0x26, 0x34, 0xf2, 0x1c, 0x19, 0x6c, 0xa9, 0x26, 0xd8, 0x23, - 0x19, 0xac, 0x4e, 0x00, 0x75, 0x60, 0xf7, 0xcf, 0x16, 0x6a, 0xcb, 0x9c, 0xc7, 0xdf, 0xa1, 0x07, - 0x83, 0x4b, 0x4a, 0xe2, 0x93, 0x28, 0x74, 0x48, 0x1c, 0x13, 0xf7, 0x84, 0x44, 0x7d, 0xe2, 0x84, - 0x81, 0xcb, 0x13, 0xa6, 0x69, 0x3d, 0xca, 0x52, 0x73, 0x11, 0x05, 0x16, 0x39, 0x58, 0x58, 0xdf, - 0x0b, 0x6a, 0xc3, 0xde, 0x29, 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 0xa9, 0xa1, 0xfd, 0x36, 0x35, 0xb4, 0xe7, - 0x53, 0x43, 0xbb, 0x9a, 0x1a, 0xda, 0x3f, 0x53, 0x43, 0xfb, 0x77, 0x6a, 0x34, 0x5e, 0x4e, 0x0d, - 0xed, 0x97, 0x1b, 0xa3, 0x71, 0x75, 0x63, 0x34, 0x5e, 0xdc, 0x18, 0x8d, 0xef, 0x3f, 0x18, 0x7a, - 0x74, 0x94, 0x0c, 0xf6, 0x9c, 0x70, 0xdc, 0x1b, 0x46, 0xf6, 0xa9, 0x1d, 0xd8, 0x3d, 0x3f, 0x3c, - 0xf3, 0x7a, 0x75, 0xff, 0x42, 0x07, 0x2d, 0xfe, 0x1f, 0xf3, 0xe3, 0xff, 0x03, 0x00, 0x00, 0xff, - 0xff, 0x38, 0x60, 0xd8, 0x7d, 0xa4, 0x0e, 0x00, 0x00, + 0x14, 0x8e, 0x27, 0x75, 0xd2, 0xde, 0x3e, 0xe7, 0xb6, 0xc3, 0x64, 0x18, 0x64, 0x97, 0xc0, 0x88, + 0x22, 0x50, 0x23, 0x1e, 0x12, 0x02, 0x31, 0x12, 0x72, 0x87, 0x4a, 0x95, 0x5a, 0x51, 0x4e, 0x40, + 0x42, 0xb0, 0x72, 0xec, 0xdb, 0xc4, 0xaa, 0x63, 0xa7, 0xf6, 0x75, 0x99, 0xae, 0xe0, 0x27, 0xb0, + 0x62, 0xc3, 0x1f, 0x60, 0xc3, 0x8a, 0x15, 0x6b, 0x36, 0xb3, 0xec, 0x72, 0x56, 0x16, 0x4d, 0x37, + 0xc8, 0xab, 0x91, 0xf8, 0x03, 0xe8, 0x3e, 0xe2, 0x57, 0xec, 0x99, 0x6c, 0xea, 0x7b, 0xbe, 0xf3, + 0x7d, 0xe7, 0x3e, 0x72, 0xce, 0xb9, 0xb7, 0x68, 0x77, 0x72, 0x3e, 0xec, 0xb9, 0xfe, 0xf0, 0xc2, + 0x1d, 0xfb, 0x36, 0x71, 0x7b, 0x21, 0x35, 0x69,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c2, 0xb3, 0x4f, 0x31, 0xd6, 0x58, 0x35, 0xcf, 0x30, 0x48, + 0x47, 0xf8, 0x3d, 0xb4, 0x72, 0x11, 0x91, 0x88, 0x70, 0x6a, 0x8b, 0x53, 0xd7, 0x93, 0x58, 0xcf, + 0x40, 0xc8, 0x86, 0x78, 0x1f, 0xa1, 0x30, 0x1a, 0x88, 0x3e, 0x12, 0xf2, 0x3c, 0x6a, 0x1a, 0x1b, + 0x49, 0xac, 0xe7, 0x50, 0xc8, 0x8d, 0xf1, 0x31, 0xda, 0xe1, 0xab, 0xfb, 0xd2, 0xa3, 0x22, 0x1d, + 0x69, 0x14, 0x78, 0xc4, 0xe6, 0x49, 0xd3, 0x34, 0x3a, 0x49, 0xac, 0x57, 0xfa, 0xa1, 0x12, 0xc5, + 0x5d, 0xd4, 0x0a, 0x27, 0xae, 0x43, 0xc3, 0xce, 0x0a, 0xd7, 0x23, 0x56, 0xbf, 0x02, 0x01, 0xf9, + 0xe5, 0x9c, 0x91, 0x19, 0xd8, 0x61, 0x07, 0xe5, 0x38, 0x1c, 0x01, 0xf9, 0x4d, 0x57, 0x75, 0xea, + 0x87, 0xf4, 0xd0, 0x71, 0x29, 0x09, 0xf8, 0xe9, 0x75, 0x56, 0x4b, 0xab, 0x2a, 0xf9, 0xa1, 0x12, + 0xc5, 0x3f, 0xa1, 0x47, 0x1c, 0xef, 0xd3, 0x20, 0xb2, 0x68, 0x14, 0x10, 0xfb, 0x84, 0x50, 0xd3, + 0x36, 0xa9, 0x59, 0x4a, 0x89, 0x35, 0x1e, 0xfe, 0xdd, 0x24, 0xd6, 0x17, 0x13, 0xc0, 0x62, 0xb4, + 0xee, 0xe7, 0xa8, 0x2d, 0x7b, 0x3e, 0x6b, 0x93, 0x21, 0xf5, 0x03, 0x52, 0xea, 0xac, 0x7d, 0x86, + 0x65, 0x6d, 0x92, 0x53, 0x40, 0x7c, 0xba, 0x7f, 0xdc, 0x41, 0xcb, 0x47, 0x59, 0x6b, 0x5f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4d, 0xf9, 0xe5, 0x56, 0x6b, 0x5c, 0xdf, 0x6a, 0x8d, 0xe7, 0xb7, 0x5a, 0xe3, 0xfb, 0xf7, 0x87, + 0x0e, 0x1d, 0x45, 0x83, 0x7d, 0xcb, 0x1f, 0xf7, 0x86, 0x81, 0x79, 0x66, 0x7a, 0x66, 0xcf, 0xf5, + 0xcf, 0x9d, 0x5e, 0xd5, 0xff, 0xb7, 0x83, 0x16, 0xff, 0xef, 0xf5, 0xa3, 0xff, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x39, 0xf0, 0xb8, 0xbf, 0xfe, 0x0e, 0x00, 0x00, } func (this *Result) Equal(that interface{}) bool { @@ -1094,6 +1105,9 @@ func (this *Store) Equal(that interface{}) bool { if this.ChunkRefsFetchTime != that1.ChunkRefsFetchTime { return false } + if this.CongestionControlLatency != that1.CongestionControlLatency { + return false + } return true } func (this *Chunk) Equal(that interface{}) bool { @@ -1268,7 +1282,7 @@ func (this *Store) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 10) + s := make([]string, 0, 11) s = append(s, "&stats.Store{") s = append(s, "TotalChunksRef: "+fmt.Sprintf("%#v", this.TotalChunksRef)+",\n") s = append(s, "TotalChunksDownloaded: "+fmt.Sprintf("%#v", this.TotalChunksDownloaded)+",\n") @@ -1276,6 +1290,7 @@ func (this *Store) GoString() string { s = append(s, "QueryReferencedStructured: "+fmt.Sprintf("%#v", this.QueryReferencedStructured)+",\n") s = append(s, "Chunk: "+strings.Replace(this.Chunk.GoString(), `&`, ``, 1)+",\n") s = append(s, "ChunkRefsFetchTime: "+fmt.Sprintf("%#v", this.ChunkRefsFetchTime)+",\n") + s = append(s, "CongestionControlLatency: "+fmt.Sprintf("%#v", this.CongestionControlLatency)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -1689,6 +1704,11 @@ func (m *Store) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x68 } + if m.CongestionControlLatency != 0 { + i = encodeVarintStats(dAtA, i, uint64(m.CongestionControlLatency)) + i-- + dAtA[i] = 0x30 + } if m.ChunkRefsFetchTime != 0 { i = encodeVarintStats(dAtA, i, uint64(m.ChunkRefsFetchTime)) i-- @@ -2005,6 +2025,9 @@ func (m *Store) Size() (n int) { if m.ChunkRefsFetchTime != 0 { n += 1 + sovStats(uint64(m.ChunkRefsFetchTime)) } + if m.CongestionControlLatency != 0 { + n += 1 + sovStats(uint64(m.CongestionControlLatency)) + } if m.QueryReferencedStructured { n += 2 } @@ -2171,6 +2194,7 @@ func (this *Store) String() string { `ChunksDownloadTime:` + fmt.Sprintf("%v", this.ChunksDownloadTime) + `,`, `Chunk:` + strings.Replace(strings.Replace(this.Chunk.String(), "Chunk", "Chunk", 1), `&`, ``, 1) + `,`, `ChunkRefsFetchTime:` + fmt.Sprintf("%v", this.ChunkRefsFetchTime) + `,`, + `CongestionControlLatency:` + fmt.Sprintf("%v", this.CongestionControlLatency) + `,`, `QueryReferencedStructured:` + fmt.Sprintf("%v", this.QueryReferencedStructured) + `,`, `}`, }, "") @@ -3372,6 +3396,25 @@ func (m *Store) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CongestionControlLatency", wireType) + } + m.CongestionControlLatency = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStats + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CongestionControlLatency |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field QueryReferencedStructured", wireType) diff --git a/pkg/logqlmodel/stats/stats.proto b/pkg/logqlmodel/stats/stats.proto index d36b8e557d984..20ad6077392b6 100644 --- a/pkg/logqlmodel/stats/stats.proto +++ b/pkg/logqlmodel/stats/stats.proto @@ -136,6 +136,9 @@ message Store { // Time spent fetching chunk refs from index. int64 chunkRefsFetchTime = 5 [(gogoproto.jsontag) = "chunkRefsFetchTime"]; + + // Time spent being blocked on congestion control. + int64 congestionControlLatency = 6 [(gogoproto.jsontag) = "congestionControlLatency"]; } message Chunk { diff --git a/pkg/querier/queryrange/codec_test.go b/pkg/querier/queryrange/codec_test.go index 52e3cc8551b7f..fa6fa9e036711 100644 --- a/pkg/querier/queryrange/codec_test.go +++ b/pkg/querier/queryrange/codec_test.go @@ -1561,6 +1561,7 @@ var ( "totalDuplicates": 8 }, "chunksDownloadTime": 0, + "congestionControlLatency": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, "chunkRefsFetchTime": 0, @@ -1585,6 +1586,7 @@ var ( "totalDuplicates": 19 }, "chunksDownloadTime": 16, + "congestionControlLatency": 0, "totalChunksRef": 17, "totalChunksDownloaded": 18, "chunkRefsFetchTime": 19, @@ -2018,6 +2020,7 @@ var ( TotalDuplicates: 19, }, ChunksDownloadTime: 16, + CongestionControlLatency: 0, TotalChunksRef: 17, TotalChunksDownloaded: 18, ChunkRefsFetchTime: 19, diff --git a/pkg/querier/queryrange/prometheus_test.go b/pkg/querier/queryrange/prometheus_test.go index 4ec798b534a73..80e4f5367afb0 100644 --- a/pkg/querier/queryrange/prometheus_test.go +++ b/pkg/querier/queryrange/prometheus_test.go @@ -16,6 +16,7 @@ var emptyStats = `"stats": { "ingester" : { "store": { "chunksDownloadTime": 0, + "congestionControlLatency": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, "chunkRefsFetchTime": 0, @@ -40,6 +41,7 @@ var emptyStats = `"stats": { "querier": { "store": { "chunksDownloadTime": 0, + "congestionControlLatency": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, "chunkRefsFetchTime": 0, diff --git a/pkg/storage/chunk/client/congestion/controller.go b/pkg/storage/chunk/client/congestion/controller.go index 7b53cea12c022..f1f69a29621e6 100644 --- a/pkg/storage/chunk/client/congestion/controller.go +++ b/pkg/storage/chunk/client/congestion/controller.go @@ -10,6 +10,7 @@ import ( "github.com/go-kit/log" "golang.org/x/time/rate" + "github.com/grafana/loki/pkg/logqlmodel/stats" "github.com/grafana/loki/pkg/storage/chunk/client" ) @@ -92,6 +93,9 @@ func (a *AIMDController) GetObject(ctx context.Context, objectKey string) (io.Re // TODO(dannyk): use hedging client to handle requests, do NOT hedge retries + start := time.Now() + statsCtx := stats.FromContext(ctx) + rc, sz, err := a.retrier.Do( func(attempt int) (io.ReadCloser, int64, error) { a.metrics.requests.Add(1) @@ -111,6 +115,8 @@ func (a *AIMDController) GetObject(ctx context.Context, objectKey string) (io.Re a.metrics.backoffSec.Add(delay.Seconds()) } + statsCtx.AddCongestionControlLatency(time.Since(start)) + // It is vitally important that retries are DISABLED in the inner implementation. // Some object storage clients implement retries internally, and this will interfere here. return a.inner.GetObject(ctx, objectKey) diff --git a/pkg/storage/chunk/client/congestion/controller_test.go b/pkg/storage/chunk/client/congestion/controller_test.go index c65f1333e9199..f63d12da20a06 100644 --- a/pkg/storage/chunk/client/congestion/controller_test.go +++ b/pkg/storage/chunk/client/congestion/controller_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/atomic" + "github.com/grafana/loki/pkg/logqlmodel/stats" "github.com/grafana/loki/pkg/storage/chunk/client" ) @@ -165,8 +166,10 @@ func TestAIMDReducedThroughput(t *testing.T) { cli := newMockObjectClient(triggeredFailer{trigger: &trigger}) ctrl.Wrap(cli) + statsCtx, ctx := stats.NewContext(context.Background()) + // run for 1 second, measure the per-second rate of requests & successful responses - count, success := runAndMeasureRate(ctrl, time.Second) + count, success := runAndMeasureRate(ctx, ctrl, time.Second) require.Greater(t, count, 1.0) require.Greater(t, success, 1.0) // no time spent backing off because the per-second limit will not be hit @@ -195,7 +198,7 @@ func TestAIMDReducedThroughput(t *testing.T) { }(&trigger) // now, run the requests again but there will now be a failure rate & some throttling involved - count, success = runAndMeasureRate(ctrl, time.Second) + count, success = runAndMeasureRate(ctx, ctrl, time.Second) done <- true wg.Wait() @@ -206,9 +209,12 @@ func TestAIMDReducedThroughput(t *testing.T) { // should have fewer successful requests than total since we are failing some require.Less(t, success, count) + + // should have registered some congestion latency in stats + require.NotZero(t, statsCtx.Querier().Store.CongestionControlLatency) } -func runAndMeasureRate(ctrl Controller, duration time.Duration) (float64, float64) { +func runAndMeasureRate(ctx context.Context, ctrl Controller, duration time.Duration) (float64, float64) { var count, success float64 tick := time.NewTimer(duration) @@ -218,8 +224,6 @@ func runAndMeasureRate(ctrl Controller, duration time.Duration) (float64, float6 case <-tick.C: goto result default: - ctx := context.Background() - count++ _, _, err := ctrl.GetObject(ctx, "foo") if err == nil { diff --git a/pkg/util/marshal/legacy/marshal_test.go b/pkg/util/marshal/legacy/marshal_test.go index a3dca73ac299f..88375ad842ab1 100644 --- a/pkg/util/marshal/legacy/marshal_test.go +++ b/pkg/util/marshal/legacy/marshal_test.go @@ -59,6 +59,7 @@ var queryTests = []struct { "ingester" : { "store": { "chunksDownloadTime": 0, + "congestionControlLatency": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, "chunkRefsFetchTime": 0, @@ -83,6 +84,7 @@ var queryTests = []struct { "querier": { "store": { "chunksDownloadTime": 0, + "congestionControlLatency": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, "chunkRefsFetchTime": 0, diff --git a/pkg/util/marshal/marshal_test.go b/pkg/util/marshal/marshal_test.go index ce7a49f97e76c..ca932064ca6c3 100644 --- a/pkg/util/marshal/marshal_test.go +++ b/pkg/util/marshal/marshal_test.go @@ -27,6 +27,7 @@ const emptyStats = `{ "ingester" : { "store": { "chunksDownloadTime": 0, + "congestionControlLatency": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, "chunkRefsFetchTime": 0, @@ -51,6 +52,7 @@ const emptyStats = `{ "querier": { "store": { "chunksDownloadTime": 0, + "congestionControlLatency": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, "chunkRefsFetchTime": 0,