diff --git a/pkg/logql/metrics.go b/pkg/logql/metrics.go index 943f1316e7..382e0908ca 100644 --- a/pkg/logql/metrics.go +++ b/pkg/logql/metrics.go @@ -138,6 +138,7 @@ func RecordRangeAndInstantQueryMetrics( "queue_time", logql_stats.ConvertSecondsToNanoseconds(stats.Summary.QueueTime), "splits", stats.Summary.Splits, "shards", stats.Summary.Shards, + "chunk_refs_fetch_time", stats.ChunkRefsFetchTime(), "cache_chunk_req", stats.Caches.Chunk.EntriesRequested, "cache_chunk_hit", stats.Caches.Chunk.EntriesFound, "cache_chunk_bytes_stored", stats.Caches.Chunk.BytesSent, diff --git a/pkg/logqlmodel/stats/context.go b/pkg/logqlmodel/stats/context.go index 824d2ef55a..afd669e692 100644 --- a/pkg/logqlmodel/stats/context.go +++ b/pkg/logqlmodel/stats/context.go @@ -173,6 +173,7 @@ func (s *Store) Merge(m Store) { s.TotalChunksRef += m.TotalChunksRef s.TotalChunksDownloaded += m.TotalChunksDownloaded s.ChunksDownloadTime += m.ChunksDownloadTime + s.ChunkRefsFetchTime += m.ChunkRefsFetchTime s.Chunk.HeadChunkBytes += m.Chunk.HeadChunkBytes s.Chunk.HeadChunkNonIndexedLabelsBytes += m.Chunk.HeadChunkNonIndexedLabelsBytes s.Chunk.HeadChunkLines += m.Chunk.HeadChunkLines @@ -247,6 +248,10 @@ func (r Result) ChunksDownloadTime() time.Duration { return time.Duration(r.Querier.Store.ChunksDownloadTime + r.Ingester.Store.ChunksDownloadTime) } +func (r Result) ChunkRefsFetchTime() time.Duration { + return time.Duration(r.Querier.Store.ChunkRefsFetchTime + r.Ingester.Store.ChunkRefsFetchTime) +} + func (r Result) TotalDuplicates() int64 { return r.Querier.Store.Chunk.TotalDuplicates + r.Ingester.Store.Chunk.TotalDuplicates } @@ -320,6 +325,10 @@ func (c *Context) AddChunksDownloadTime(i time.Duration) { atomic.AddInt64(&c.store.ChunksDownloadTime, int64(i)) } +func (c *Context) AddChunkRefsFetchTime(i time.Duration) { + atomic.AddInt64(&c.store.ChunkRefsFetchTime, int64(i)) +} + func (c *Context) AddChunksDownloaded(i int64) { atomic.AddInt64(&c.store.TotalChunksDownloaded, i) } @@ -433,6 +442,7 @@ func (r Result) Log(log log.Logger) { "Ingester.TotalChunksRef", r.Ingester.Store.TotalChunksRef, "Ingester.TotalChunksDownloaded", r.Ingester.Store.TotalChunksDownloaded, "Ingester.ChunksDownloadTime", time.Duration(r.Ingester.Store.ChunksDownloadTime), + "Ingester.ChunkRefsFetchTime", time.Duration(r.Ingester.Store.ChunkRefsFetchTime), "Ingester.HeadChunkBytes", humanize.Bytes(uint64(r.Ingester.Store.Chunk.HeadChunkBytes)), "Ingester.HeadChunkLines", r.Ingester.Store.Chunk.HeadChunkLines, "Ingester.DecompressedBytes", humanize.Bytes(uint64(r.Ingester.Store.Chunk.DecompressedBytes)), @@ -444,6 +454,7 @@ func (r Result) Log(log log.Logger) { "Querier.TotalChunksRef", r.Querier.Store.TotalChunksRef, "Querier.TotalChunksDownloaded", r.Querier.Store.TotalChunksDownloaded, "Querier.ChunksDownloadTime", time.Duration(r.Querier.Store.ChunksDownloadTime), + "Querier.ChunkRefsFetchTime", time.Duration(r.Querier.Store.ChunkRefsFetchTime), "Querier.HeadChunkBytes", humanize.Bytes(uint64(r.Querier.Store.Chunk.HeadChunkBytes)), "Querier.HeadChunkLines", r.Querier.Store.Chunk.HeadChunkLines, "Querier.DecompressedBytes", humanize.Bytes(uint64(r.Querier.Store.Chunk.DecompressedBytes)), diff --git a/pkg/logqlmodel/stats/stats.pb.go b/pkg/logqlmodel/stats/stats.pb.go index 8ebca564fe..9a4fed2dd7 100644 --- a/pkg/logqlmodel/stats/stats.pb.go +++ b/pkg/logqlmodel/stats/stats.pb.go @@ -440,6 +440,8 @@ type Store struct { // Time spent fetching chunks in nanoseconds. ChunksDownloadTime int64 `protobuf:"varint,3,opt,name=chunksDownloadTime,proto3" json:"chunksDownloadTime"` 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"` } func (m *Store) Reset() { *m = Store{} } @@ -502,6 +504,13 @@ func (m *Store) GetChunk() Chunk { return Chunk{} } +func (m *Store) GetChunkRefsFetchTime() int64 { + if m != nil { + return m.ChunkRefsFetchTime + } + return 0 +} + type Chunk struct { // Total bytes processed but was already in memory (found in the headchunk). Includes non-indexed labels bytes. HeadChunkBytes int64 `protobuf:"varint,4,opt,name=headChunkBytes,proto3" json:"headChunkBytes"` @@ -723,75 +732,76 @@ func init() { func init() { proto.RegisterFile("pkg/logqlmodel/stats/stats.proto", fileDescriptor_6cdfe5d2aea33ebb) } var fileDescriptor_6cdfe5d2aea33ebb = []byte{ - // 1083 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0xcd, 0x6f, 0xe3, 0x44, - 0x14, 0x8f, 0x5b, 0x9c, 0xb4, 0xd3, 0xcf, 0x9d, 0x76, 0x59, 0x03, 0x92, 0x5d, 0x82, 0x10, 0x95, - 0x40, 0x8d, 0xf8, 0x90, 0x10, 0x88, 0x95, 0x90, 0xbb, 0x54, 0xaa, 0x54, 0xa0, 0xbc, 0xc2, 0x85, - 0x9b, 0x63, 0xcf, 0xa6, 0xa6, 0x8e, 0x9d, 0x7a, 0x6c, 0xd8, 0xde, 0xf8, 0x0f, 0xe0, 0xbf, 0x80, - 0x0b, 0x27, 0xfe, 0x89, 0x3d, 0xf6, 0xb8, 0x27, 0x8b, 0xa6, 0x17, 0xf0, 0x69, 0x25, 0xee, 0x08, - 0xcd, 0x9b, 0x89, 0xbf, 0xe2, 0xa8, 0xbd, 0xc4, 0xf3, 0x7e, 0x1f, 0x33, 0xe3, 0x19, 0xbf, 0x37, - 0x13, 0xb2, 0x37, 0xb9, 0x18, 0x0d, 0x82, 0x68, 0x74, 0x19, 0x8c, 0x23, 0x8f, 0x05, 0x03, 0x9e, - 0x38, 0x09, 0x97, 0xbf, 0x07, 0x93, 0x38, 0x4a, 0x22, 0xaa, 0x63, 0xf0, 0xfa, 0xee, 0x28, 0x1a, - 0x45, 0x88, 0x0c, 0x44, 0x4b, 0x92, 0xfd, 0x7f, 0x35, 0xd2, 0x05, 0xc6, 0xd3, 0x20, 0xa1, 0x9f, - 0x90, 0x1e, 0x4f, 0xc7, 0x63, 0x27, 0xbe, 0x32, 0xb4, 0x3d, 0x6d, 0x7f, 0xed, 0x83, 0xcd, 0x03, - 0xd9, 0xcd, 0x99, 0x44, 0xed, 0xad, 0xe7, 0x99, 0xd5, 0xc9, 0x33, 0x6b, 0x26, 0x83, 0x59, 0x43, - 0x58, 0x2f, 0x53, 0x16, 0xfb, 0x2c, 0x36, 0x96, 0x6a, 0xd6, 0x6f, 0x24, 0x5a, 0x5a, 0x95, 0x0c, - 0x66, 0x0d, 0xfa, 0x98, 0xac, 0xf8, 0xe1, 0x88, 0xf1, 0x84, 0xc5, 0xc6, 0x32, 0x7a, 0xb7, 0x94, - 0xf7, 0x58, 0xc1, 0xf6, 0xb6, 0x32, 0x17, 0x42, 0x28, 0x5a, 0xf4, 0x23, 0xd2, 0x75, 0x1d, 0xf7, - 0x9c, 0x71, 0xe3, 0x15, 0x34, 0x6f, 0x28, 0xf3, 0x21, 0x82, 0xf6, 0x86, 0xb2, 0xea, 0x28, 0x02, - 0xa5, 0xed, 0xff, 0xa3, 0x91, 0xae, 0x54, 0xd0, 0xf7, 0x89, 0xee, 0x9e, 0xa7, 0xe1, 0x85, 0x7a, - 0xe7, 0xf5, 0xaa, 0xbf, 0x62, 0x17, 0x12, 0x90, 0x0f, 0x61, 0xf1, 0x43, 0x8f, 0x3d, 0x53, 0xef, - 0xba, 0xc0, 0x82, 0x12, 0x90, 0x0f, 0x31, 0xcd, 0x18, 0x57, 0x59, 0xbd, 0x63, 0xdd, 0xb3, 0xa9, - 0x3c, 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x4f, 0xcd, 0xce, 0xcb, - 0xa9, 0xa9, 0xfd, 0x7a, 0x6b, 0x76, 0xae, 0x6f, 0xcd, 0xce, 0x8b, 0x5b, 0xb3, 0xf3, 0xfd, 0x7b, - 0x23, 0x3f, 0x39, 0x4f, 0x87, 0x07, 0x6e, 0x34, 0x1e, 0x8c, 0x62, 0xe7, 0xa9, 0x13, 0x3a, 0x83, - 0x20, 0xba, 0xf0, 0x07, 0x6d, 0xff, 0x27, 0x86, 0x5d, 0xfc, 0xb7, 0xf0, 0xe1, 0xff, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xe6, 0xbb, 0xa2, 0x88, 0x6e, 0x0c, 0x00, 0x00, + // 1102 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0x5b, 0x9c, 0x74, 0x67, 0xdb, 0x6e, 0x77, 0xda, 0x65, 0x0d, 0x48, 0x76, 0x09, 0x42, + 0x54, 0x02, 0x35, 0xe2, 0x8f, 0x84, 0x40, 0xac, 0x84, 0xdc, 0xa5, 0x52, 0xa5, 0x02, 0xe5, 0x15, + 0x2e, 0xdc, 0x1c, 0x7b, 0x9a, 0x98, 0x3a, 0x76, 0xea, 0xb1, 0x61, 0x7b, 0xe3, 0x23, 0xf0, 0x2d, + 0xe0, 0xc2, 0x89, 0x2f, 0xb1, 0xc7, 0xde, 0xd8, 0x93, 0x45, 0xd3, 0x0b, 0xf8, 0xb4, 0x12, 0x77, + 0x84, 0xe6, 0xcd, 0xc4, 0xff, 0xe2, 0xa8, 0xbd, 0xc4, 0xf3, 0x7e, 0x7f, 0xe6, 0x8d, 0xc7, 0x7e, + 0xcf, 0x13, 0xb2, 0x3b, 0x3d, 0x1f, 0x0d, 0x82, 0x68, 0x74, 0x11, 0x4c, 0x22, 0x8f, 0x05, 0x03, + 0x9e, 0x38, 0x09, 0x97, 0xbf, 0xfb, 0xd3, 0x38, 0x4a, 0x22, 0xaa, 0x63, 0xf0, 0xfa, 0xce, 0x28, + 0x1a, 0x45, 0x88, 0x0c, 0xc4, 0x48, 0x92, 0xfd, 0x7f, 0x35, 0xd2, 0x05, 0xc6, 0xd3, 0x20, 0xa1, + 0x9f, 0x90, 0x1e, 0x4f, 0x27, 0x13, 0x27, 0xbe, 0x34, 0xb4, 0x5d, 0x6d, 0xef, 0xfe, 0x07, 0x9b, + 0xfb, 0x72, 0x9a, 0x53, 0x89, 0xda, 0x0f, 0x9e, 0x67, 0x56, 0x27, 0xcf, 0xac, 0xb9, 0x0c, 0xe6, + 0x03, 0x61, 0xbd, 0x48, 0x59, 0xec, 0xb3, 0xd8, 0x58, 0xa9, 0x59, 0xbf, 0x91, 0x68, 0x69, 0x55, + 0x32, 0x98, 0x0f, 0xe8, 0x13, 0xb2, 0xe6, 0x87, 0x23, 0xc6, 0x13, 0x16, 0x1b, 0xab, 0xe8, 0x7d, + 0xa0, 0xbc, 0x47, 0x0a, 0xb6, 0xb7, 0x94, 0xb9, 0x10, 0x42, 0x31, 0xa2, 0x1f, 0x91, 0xae, 0xeb, + 0xb8, 0x63, 0xc6, 0x8d, 0x57, 0xd0, 0xbc, 0xa1, 0xcc, 0x07, 0x08, 0xda, 0x1b, 0xca, 0xaa, 0xa3, + 0x08, 0x94, 0xb6, 0xff, 0x8f, 0x46, 0xba, 0x52, 0x41, 0xdf, 0x27, 0xba, 0x3b, 0x4e, 0xc3, 0x73, + 0x75, 0xcf, 0xeb, 0x55, 0x7f, 0xc5, 0x2e, 0x24, 0x20, 0x2f, 0xc2, 0xe2, 0x87, 0x1e, 0x7b, 0xa6, + 0xee, 0x75, 0x89, 0x05, 0x25, 0x20, 0x2f, 0x62, 0x99, 0x31, 0xee, 0xb2, 0xba, 0xc7, 0xba, 0x67, + 0x53, 0x79, 0x94, 0x06, 0xd4, 0x95, 0x1e, 0x90, 0xfb, 0x28, 0x93, 0x0f, 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e9, 0xf2, 0x69, 0xe0, 0x27, 0xdc, 0xb8, 0x87, 0x7e, 0x22, 0xde, 0x46, 0x89, + 0x80, 0xba, 0xa2, 0x66, 0xec, 0xc4, 0x1e, 0x37, 0x48, 0x45, 0x83, 0x08, 0xa8, 0x6b, 0xb1, 0xaa, + 0x93, 0x88, 0x27, 0x87, 0x7e, 0x90, 0xb0, 0x18, 0x77, 0xcf, 0xb8, 0xdf, 0x58, 0x55, 0x83, 0x87, + 0x56, 0x94, 0x5e, 0x92, 0xb7, 0x10, 0xff, 0x2a, 0x0a, 0x8f, 0x44, 0x19, 0x31, 0xef, 0xd8, 0x19, + 0xb2, 0x80, 0x37, 0x5e, 0x88, 0x75, 0x9c, 0xfc, 0x9d, 0x3c, 0xb3, 0xee, 0x22, 0x87, 0xbb, 0x88, + 0xfa, 0x9f, 0x91, 0x9e, 0xea, 0x5d, 0xa2, 0xdc, 0x79, 0x12, 0xc5, 0xac, 0xd1, 0x21, 0x4e, 0x05, + 0x56, 0x96, 0x3b, 0x4a, 0x40, 0x5e, 0xfa, 0xbf, 0xaf, 0x90, 0xb5, 0xa3, 0xb2, 0x45, 0xad, 0x63, + 0x46, 0x60, 0xa2, 0x62, 0x65, 0xa5, 0xe9, 0xf6, 0x56, 0x9e, 0x59, 0x35, 0x1c, 0x6a, 0x11, 0x3d, + 0x24, 0x14, 0xe3, 0x03, 0xd1, 0x72, 0xf8, 0x97, 0x4e, 0x82, 0x5e, 0x59, 0x4e, 0xaf, 0xe6, 0x99, + 0xd5, 0xc2, 0x42, 0x0b, 0x56, 0x64, 0xb7, 0x31, 0xe6, 0xaa, 0x7a, 0xca, 0xec, 0x0a, 0x87, 0x5a, + 0x44, 0x3f, 0x25, 0x9b, 0xe5, 0xbb, 0x7f, 0xca, 0xc2, 0x44, 0x95, 0x0a, 0xcd, 0x33, 0xab, 0xc1, + 0x40, 0x23, 0x2e, 0xf7, 0x4b, 0xbf, 0xf3, 0x7e, 0xfd, 0xb9, 0x42, 0x74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0x9f, 0x99, 0xda, 0xd5, 0xcc, 0xd4, 0xfe, 0x9a, 0x99, 0xda, 0xdf, + 0x33, 0xb3, 0xf3, 0x72, 0x66, 0x6a, 0xbf, 0xdc, 0x98, 0x9d, 0xab, 0x1b, 0xb3, 0xf3, 0xe2, 0xc6, + 0xec, 0x7c, 0xff, 0xde, 0xc8, 0x4f, 0xc6, 0xe9, 0x70, 0xdf, 0x8d, 0x26, 0x83, 0x51, 0xec, 0x9c, + 0x39, 0xa1, 0x33, 0x08, 0xa2, 0x73, 0x7f, 0xd0, 0xf6, 0xbf, 0x64, 0xd8, 0xc5, 0x7f, 0x1d, 0x1f, + 0xfe, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xe6, 0xd2, 0x99, 0xf1, 0xb6, 0x0c, 0x00, 0x00, } func (this *Result) Equal(that interface{}) bool { @@ -1008,6 +1018,9 @@ func (this *Store) Equal(that interface{}) bool { if !this.Chunk.Equal(&that1.Chunk) { return false } + if this.ChunkRefsFetchTime != that1.ChunkRefsFetchTime { + return false + } return true } func (this *Chunk) Equal(that interface{}) bool { @@ -1175,12 +1188,13 @@ func (this *Store) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 8) + s := make([]string, 0, 9) 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") s = append(s, "ChunksDownloadTime: "+fmt.Sprintf("%#v", this.ChunksDownloadTime)+",\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, "}") return strings.Join(s, "") } @@ -1543,6 +1557,11 @@ func (m *Store) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ChunkRefsFetchTime != 0 { + i = encodeVarintStats(dAtA, i, uint64(m.ChunkRefsFetchTime)) + i-- + dAtA[i] = 0x28 + } { size, err := m.Chunk.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -1838,6 +1857,9 @@ func (m *Store) Size() (n int) { } l = m.Chunk.Size() n += 1 + l + sovStats(uint64(l)) + if m.ChunkRefsFetchTime != 0 { + n += 1 + sovStats(uint64(m.ChunkRefsFetchTime)) + } return n } @@ -1993,6 +2015,7 @@ func (this *Store) String() string { `TotalChunksDownloaded:` + fmt.Sprintf("%v", this.TotalChunksDownloaded) + `,`, `ChunksDownloadTime:` + fmt.Sprintf("%v", this.ChunksDownloadTime) + `,`, `Chunk:` + strings.Replace(strings.Replace(this.Chunk.String(), "Chunk", "Chunk", 1), `&`, ``, 1) + `,`, + `ChunkRefsFetchTime:` + fmt.Sprintf("%v", this.ChunkRefsFetchTime) + `,`, `}`, }, "") return s @@ -3041,6 +3064,25 @@ func (m *Store) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChunkRefsFetchTime", wireType) + } + m.ChunkRefsFetchTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStats + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChunkRefsFetchTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipStats(dAtA[iNdEx:]) diff --git a/pkg/logqlmodel/stats/stats.proto b/pkg/logqlmodel/stats/stats.proto index 019bc39651..1faed5389c 100644 --- a/pkg/logqlmodel/stats/stats.proto +++ b/pkg/logqlmodel/stats/stats.proto @@ -115,6 +115,9 @@ message Store { (gogoproto.nullable) = false, (gogoproto.jsontag) = "chunk" ]; + + // Time spent fetching chunk refs from index. + int64 chunkRefsFetchTime = 5 [(gogoproto.jsontag) = "chunkRefsFetchTime"]; } message Chunk { diff --git a/pkg/querier/http_test.go b/pkg/querier/http_test.go index cd8ad1062b..1a619396fd 100644 --- a/pkg/querier/http_test.go +++ b/pkg/querier/http_test.go @@ -41,7 +41,8 @@ var ( }, "chunksDownloadTime": 0, "totalChunksRef": 0, - "totalChunksDownloaded": 0 + "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0 }, "totalBatches": 6, "totalChunksMatched": 7, @@ -63,7 +64,8 @@ var ( }, "chunksDownloadTime": 16, "totalChunksRef": 17, - "totalChunksDownloaded": 18 + "totalChunksDownloaded": 18, + "chunkRefsFetchTime": 0 } }, "cache": { diff --git a/pkg/querier/queryrange/codec_test.go b/pkg/querier/queryrange/codec_test.go index 2d124e0a76..730a459f3e 100644 --- a/pkg/querier/queryrange/codec_test.go +++ b/pkg/querier/queryrange/codec_test.go @@ -1349,7 +1349,8 @@ var ( }, "chunksDownloadTime": 0, "totalChunksRef": 0, - "totalChunksDownloaded": 0 + "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0 }, "totalBatches": 6, "totalChunksMatched": 7, @@ -1371,7 +1372,8 @@ var ( }, "chunksDownloadTime": 16, "totalChunksRef": 17, - "totalChunksDownloaded": 18 + "totalChunksDownloaded": 18, + "chunkRefsFetchTime": 19 } }, "cache": { @@ -1607,6 +1609,7 @@ var ( ChunksDownloadTime: 16, TotalChunksRef: 17, TotalChunksDownloaded: 18, + ChunkRefsFetchTime: 19, }, }, diff --git a/pkg/querier/queryrange/prometheus_test.go b/pkg/querier/queryrange/prometheus_test.go index ff194d9461..0ca6b62e6b 100644 --- a/pkg/querier/queryrange/prometheus_test.go +++ b/pkg/querier/queryrange/prometheus_test.go @@ -18,6 +18,7 @@ var emptyStats = `"stats": { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, @@ -40,6 +41,7 @@ var emptyStats = `"stats": { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, diff --git a/pkg/storage/store.go b/pkg/storage/store.go index be62a5ce85..6b7f749079 100644 --- a/pkg/storage/store.go +++ b/pkg/storage/store.go @@ -394,7 +394,10 @@ func (s *store) lazyChunks(ctx context.Context, matchers []*labels.Matcher, from stats := stats.FromContext(ctx) + start := time.Now() chks, fetchers, err := s.GetChunkRefs(ctx, userID, from, through, matchers...) + stats.AddChunkRefsFetchTime(time.Since(start)) + if err != nil { return nil, err } diff --git a/pkg/util/marshal/legacy/marshal_test.go b/pkg/util/marshal/legacy/marshal_test.go index 0e0bba9121..91397c03ea 100644 --- a/pkg/util/marshal/legacy/marshal_test.go +++ b/pkg/util/marshal/legacy/marshal_test.go @@ -65,6 +65,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, @@ -87,6 +88,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, diff --git a/pkg/util/marshal/marshal_test.go b/pkg/util/marshal/marshal_test.go index 2ebc27983b..a2b436b1a5 100644 --- a/pkg/util/marshal/marshal_test.go +++ b/pkg/util/marshal/marshal_test.go @@ -67,6 +67,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, @@ -89,6 +90,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, @@ -221,6 +223,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, @@ -243,6 +246,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, @@ -396,6 +400,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0, @@ -418,6 +423,7 @@ var queryTests = []struct { "chunksDownloadTime": 0, "totalChunksRef": 0, "totalChunksDownloaded": 0, + "chunkRefsFetchTime": 0, "chunk" :{ "compressedBytes": 0, "decompressedBytes": 0,