diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index 34cca0189a..474ffe51ce 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -1173,7 +1173,7 @@ func (i *Ingester) GetSeriesVolume(ctx context.Context, req *logproto.VolumeRequ ctx, len(jobs), 2, - func(ctx context.Context, idx int) error { + func(_ context.Context, idx int) error { res, err := jobs[idx]() resps[idx] = res return err diff --git a/pkg/ingester/instance.go b/pkg/ingester/instance.go index 1e7ce267ed..f4b1374f32 100644 --- a/pkg/ingester/instance.go +++ b/pkg/ingester/instance.go @@ -686,7 +686,7 @@ func (i *instance) GetSeriesVolume(ctx context.Context, req *logproto.VolumeRequ return nil, err } - res := seriesvolume.MapToSeriesVolumeResponse(volumes, int(req.Limit)) + res := seriesvolume.MapToSeriesVolumeResponse(volumes, int(req.Limit), from, through) return res, nil } diff --git a/pkg/ingester/instance_test.go b/pkg/ingester/instance_test.go index 73b46de321..3c682c15ba 100644 --- a/pkg/ingester/instance_test.go +++ b/pkg/ingester/instance_test.go @@ -843,7 +843,7 @@ func TestInstance_SeriesVolume(t *testing.T) { instance := defaultInstance(t) volumes, err := instance.GetSeriesVolume(context.Background(), &logproto.VolumeRequest{ From: 0, - Through: 11000, + Through: 1.1 * 1e3, //milliseconds Matchers: "{}", Limit: 2, }) @@ -859,7 +859,7 @@ func TestInstance_SeriesVolume(t *testing.T) { instance := defaultInstance(t) volumes, err := instance.GetSeriesVolume(context.Background(), &logproto.VolumeRequest{ From: 0, - Through: 11000, + Through: 1.1 * 1e3, //milliseconds Matchers: `{log_stream="dispatcher"}`, Limit: 2, }) @@ -874,7 +874,7 @@ func TestInstance_SeriesVolume(t *testing.T) { instance := defaultInstance(t) volumes, err := instance.GetSeriesVolume(context.Background(), &logproto.VolumeRequest{ From: 5, - Through: 11, + Through: 1.1 * 1e3, //milliseconds Matchers: "{}", Limit: 3, }) diff --git a/pkg/logproto/logproto.pb.go b/pkg/logproto/logproto.pb.go index a0bd54f6bb..10ec607648 100644 --- a/pkg/logproto/logproto.pb.go +++ b/pkg/logproto/logproto.pb.go @@ -2339,8 +2339,10 @@ func (m *VolumeRequest) GetLimit() int32 { } type VolumeResponse struct { - Volumes []Volume `protobuf:"bytes,1,rep,name=volumes,proto3" json:"volumes"` - Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + Volumes []Volume `protobuf:"bytes,1,rep,name=volumes,proto3" json:"volumes"` + Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + From github_com_prometheus_common_model.Time `protobuf:"varint,3,opt,name=from,proto3,customtype=github.com/prometheus/common/model.Time" json:"from"` + Through github_com_prometheus_common_model.Time `protobuf:"varint,4,opt,name=through,proto3,customtype=github.com/prometheus/common/model.Time" json:"through"` } func (m *VolumeResponse) Reset() { *m = VolumeResponse{} } @@ -2501,145 +2503,146 @@ func init() { func init() { proto.RegisterFile("pkg/logproto/logproto.proto", fileDescriptor_c28a5f14f1f4c79a) } var fileDescriptor_c28a5f14f1f4c79a = []byte{ - // 2205 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x19, 0x4d, 0x8f, 0x1b, 0x49, - 0xd5, 0x65, 0xb7, 0xbf, 0x9e, 0xed, 0x19, 0xa7, 0xc6, 0x9b, 0x18, 0x27, 0xb1, 0x27, 0xad, 0x25, - 0x19, 0x25, 0x59, 0x7b, 0x33, 0x0b, 0x4b, 0x36, 0x61, 0x41, 0xf1, 0xcc, 0x26, 0x3b, 0xf9, 0xde, - 0x9a, 0x10, 0xd0, 0x8a, 0x55, 0xd4, 0x63, 0x97, 0x3f, 0x34, 0x6e, 0xb7, 0xd3, 0xdd, 0xde, 0xec, - 0x48, 0x1c, 0xf8, 0x03, 0x2b, 0xed, 0x0d, 0x71, 0x41, 0x1c, 0x90, 0x40, 0x48, 0x5c, 0xf8, 0x01, - 0xc0, 0x01, 0x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, 0x26, 0x92, 0x7e, 0xb1, 0xd3, 0xff, 0x8c, 0xa0, 0x78, 0xd3, 0xda, 0xa1, - 0x23, 0x15, 0x69, 0x18, 0x8c, 0xb1, 0x65, 0x53, 0x69, 0x71, 0xfe, 0xcd, 0xd2, 0xfe, 0x63, 0x6b, - 0x34, 0xa5, 0x82, 0x65, 0x8e, 0x48, 0x68, 0xd1, 0x9c, 0x45, 0x2f, 0x9c, 0xb3, 0x28, 0x8c, 0xbc, - 0x0a, 0xa4, 0x1f, 0x32, 0x43, 0xf1, 0x7c, 0xcd, 0x13, 0x01, 0x98, 0x67, 0xa0, 0x24, 0xb5, 0x90, - 0xe6, 0x0b, 0x45, 0x66, 0xe6, 0xcb, 0x2b, 0x91, 0x4d, 0x1b, 0x32, 0xc2, 0xda, 0xf8, 0x75, 0xc8, - 0x07, 0x3d, 0x80, 0x6b, 0x9b, 0x6a, 0x67, 0x0e, 0x66, 0x8d, 0xa4, 0xef, 0x91, 0x70, 0x01, 0x37, - 0x20, 0xcd, 0x77, 0x72, 0xcd, 0x51, 0x3b, 0x7f, 0x30, 0x6b, 0x08, 0x04, 0x11, 0x3f, 0xf8, 0x04, - 0x18, 0x03, 0x56, 0x86, 0x99, 0x09, 0x8c, 0x76, 0xee, 0x60, 0xd6, 0xe0, 0x30, 0xe1, 0x7f, 0xcd, - 0x6b, 0x50, 0xbc, 0x49, 0xfb, 0x56, 0x67, 0x4f, 0x1e, 0x5a, 0x51, 0xec, 0xd8, 0x81, 0x48, 0xf1, - 0x38, 0x05, 0xc5, 0xe0, 0xc4, 0x07, 0xb6, 0x27, 0x83, 0xba, 0x10, 0xe0, 0x6e, 0x79, 0xe6, 0xcf, - 0x11, 0x48, 0x3f, 0x63, 0x13, 0x32, 0x23, 0xa6, 0xab, 0x27, 0x7c, 0xd4, 0x86, 0x83, 0x59, 0x43, - 0x62, 0x88, 0xfc, 0xc5, 0x97, 0x21, 0xeb, 0xf1, 0x13, 0x19, 0xb3, 0x78, 0xf8, 0xf0, 0x85, 0xf6, - 0x32, 0x0b, 0x83, 0x83, 0x59, 0x43, 0x11, 0x12, 0xf5, 0x81, 0x9b, 0x91, 0xfe, 0x22, 0x14, 0x5b, - 0x3a, 0x98, 0x35, 0x34, 0xac, 0xde, 0x6f, 0xcc, 0x9f, 0x21, 0x28, 0xdc, 0xb3, 0x86, 0x41, 0x08, - 0x05, 0x2e, 0x42, 0x9a, 0x8b, 0x58, 0x3a, 0x77, 0xe9, 0xc8, 0xda, 0xbb, 0xea, 0xb8, 0x9c, 0x67, - 0x89, 0x04, 0x70, 0xd8, 0x12, 0x8c, 0xb9, 0x2d, 0x21, 0xbd, 0x70, 0x61, 0xbb, 0x6e, 0xe4, 0x92, - 0xe5, 0x94, 0xf9, 0x3b, 0x04, 0x45, 0x21, 0x99, 0x0c, 0x8b, 0x1f, 0x43, 0x46, 0x08, 0xce, 0x65, - 0xfb, 0x92, 0xe4, 0x3f, 0xb7, 0x48, 0xe2, 0x4b, 0x9e, 0xf8, 0xfb, 0xb0, 0xd4, 0x75, 0x9d, 0xc9, - 0x84, 0x76, 0xb7, 0x65, 0x89, 0x49, 0xc6, 0x4b, 0xcc, 0xa6, 0xbe, 0x4e, 0x62, 0xe4, 0xe6, 0x5f, - 0x11, 0x94, 0x64, 0x36, 0x4b, 0x5b, 0x06, 0x36, 0x40, 0x2f, 0x5c, 0xdc, 0x93, 0x8b, 0x16, 0xf7, - 0xa3, 0x90, 0xe9, 0xbb, 0xce, 0x74, 0xe2, 0x55, 0x53, 0x22, 0x77, 0x04, 0xb4, 0x58, 0xd1, 0x37, - 0xaf, 0xc3, 0x92, 0x52, 0xe5, 0x39, 0x25, 0xad, 0x16, 0x2f, 0x69, 0x5b, 0x5d, 0x3a, 0xf6, 0x87, - 0xbd, 0x61, 0x50, 0xa4, 0x24, 0xbd, 0xf9, 0x29, 0x82, 0x72, 0x9c, 0x04, 0x7f, 0x4f, 0xcb, 0x03, - 0xc6, 0xee, 0xf4, 0xf3, 0xd9,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xaa, 0xb6, 0x34, 0x7f, 0x70, 0x4c, 0xac, 0xa1, 0xf5, - 0x8f, 0xd4, 0xbf, 0x6f, 0x36, 0x2d, 0xdf, 0xc2, 0x77, 0x60, 0x89, 0x6b, 0x1f, 0xfc, 0x7f, 0x27, - 0x12, 0xa5, 0x87, 0xfe, 0x99, 0x14, 0x89, 0xd2, 0xc3, 0xff, 0x54, 0x32, 0x13, 0xed, 0x0f, 0x9f, - 0x3c, 0xad, 0x27, 0x3e, 0x7f, 0x5a, 0x4f, 0x7c, 0xf1, 0xb4, 0x8e, 0x7e, 0xba, 0x5f, 0x47, 0xbf, - 0xd9, 0xaf, 0xa3, 0xc7, 0xfb, 0x75, 0xf4, 0x64, 0xbf, 0x8e, 0xfe, 0xb9, 0x5f, 0x47, 0xff, 0xda, - 0xaf, 0x27, 0xbe, 0xd8, 0xaf, 0xa3, 0xcf, 0x9e, 0xd5, 0x13, 0x4f, 0x9e, 0xd5, 0x13, 0x9f, 0x3f, - 0xab, 0x27, 0x3e, 0x7c, 0xfd, 0xcb, 0x5e, 0xb7, 0xd4, 0x89, 0x3b, 0x19, 0xfe, 0xf3, 0xd6, 0x7f, - 0x03, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x2d, 0xf5, 0x83, 0x7d, 0x1b, 0x00, 0x00, + // 2213 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x39, 0xcd, 0x6f, 0x1b, 0xc7, + 0xf5, 0x1c, 0x72, 0x49, 0x91, 0x8f, 0xd4, 0x87, 0x47, 0x8c, 0xad, 0x1f, 0x6d, 0x93, 0xf2, 0x20, + 0x3f, 0x5b, 0xb0, 0x1d, 0x32, 0x56, 0xda, 0xd4, 0xb1, 0x9b, 0x16, 0xa6, 0x14, 0x3b, 0xf2, 0x77, + 0x46, 0xae, 0x0b, 0x04, 0x0d, 0x8c, 0x15, 0x39, 0xfc, 0x80, 0xb8,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, 0x57, 0x61, 0x31, 0xbc, 0x2b, 0xa8, + 0xa8, 0x3e, 0x96, 0x4c, 0xd3, 0x29, 0xf6, 0x8a, 0xa7, 0x3a, 0x49, 0xad, 0x7f, 0x04, 0x79, 0x3d, + 0x96, 0xe3, 0x0f, 0x60, 0x21, 0x3e, 0x94, 0xe2, 0xff, 0x33, 0xcc, 0x13, 0x9f, 0xf5, 0x2b, 0xab, + 0xc6, 0xd2, 0xf4, 0x49, 0x36, 0xb5, 0x86, 0xd6, 0x3f, 0xd2, 0xff, 0x4f, 0xda, 0xb4, 0x03, 0x1b, + 0xdf, 0x81, 0x05, 0xa1, 0x7d, 0xf8, 0x0f, 0xa7, 0x58, 0x94, 0x1e, 0xfa, 0xef, 0x56, 0x2c, 0x4a, + 0x0f, 0xff, 0x97, 0x8b, 0xa4, 0x9a, 0x1f, 0x3e, 0x79, 0x5a, 0x4d, 0x7d, 0xfe, 0xb4, 0x9a, 0xfa, + 0xf2, 0x69, 0x15, 0xfd, 0x64, 0xbf, 0x8a, 0x7e, 0xbd, 0x5f, 0x45, 0x8f, 0xf7, 0xab, 0xe8, 0xc9, + 0x7e, 0x15, 0xfd, 0x63, 0xbf, 0x8a, 0xbe, 0xd8, 0xaf, 0xa6, 0xbe, 0xdc, 0xaf, 0xa2, 0xcf, 0x9e, + 0x55, 0x53, 0x4f, 0x9e, 0x55, 0x53, 0x9f, 0x3f, 0xab, 0xa6, 0x3e, 0x7c, 0xfd, 0xab, 0x9e, 0xdb, + 0xf4, 0x89, 0x3b, 0x39, 0xf1, 0xf3, 0xd6, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3e, 0x47, 0x25, + 0xcf, 0x0e, 0x1c, 0x00, 0x00, } func (x Direction) String() string { @@ -4037,6 +4040,12 @@ func (this *VolumeResponse) Equal(that interface{}) bool { if this.Limit != that1.Limit { return false } + if !this.From.Equal(that1.From) { + return false + } + if !this.Through.Equal(that1.Through) { + return false + } return true } func (this *Volume) Equal(that interface{}) bool { @@ -4619,7 +4628,7 @@ func (this *VolumeResponse) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 6) + s := make([]string, 0, 8) s = append(s, "&logproto.VolumeResponse{") if this.Volumes != nil { vs := make([]*Volume, len(this.Volumes)) @@ -4629,6 +4638,8 @@ func (this *VolumeResponse) GoString() string { s = append(s, "Volumes: "+fmt.Sprintf("%#v", vs)+",\n") } s = append(s, "Limit: "+fmt.Sprintf("%#v", this.Limit)+",\n") + s = append(s, "From: "+fmt.Sprintf("%#v", this.From)+",\n") + s = append(s, "Through: "+fmt.Sprintf("%#v", this.Through)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -7161,6 +7172,16 @@ func (m *VolumeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Through != 0 { + i = encodeVarintLogproto(dAtA, i, uint64(m.Through)) + i-- + dAtA[i] = 0x20 + } + if m.From != 0 { + i = encodeVarintLogproto(dAtA, i, uint64(m.From)) + i-- + dAtA[i] = 0x18 + } if m.Limit != 0 { i = encodeVarintLogproto(dAtA, i, uint64(m.Limit)) i-- @@ -8063,6 +8084,12 @@ func (m *VolumeResponse) Size() (n int) { if m.Limit != 0 { n += 1 + sovLogproto(uint64(m.Limit)) } + if m.From != 0 { + n += 1 + sovLogproto(uint64(m.From)) + } + if m.Through != 0 { + n += 1 + sovLogproto(uint64(m.Through)) + } return n } @@ -8672,6 +8699,8 @@ func (this *VolumeResponse) String() string { s := strings.Join([]string{`&VolumeResponse{`, `Volumes:` + repeatedStringForVolumes + `,`, `Limit:` + fmt.Sprintf("%v", this.Limit) + `,`, + `From:` + fmt.Sprintf("%v", this.From) + `,`, + `Through:` + fmt.Sprintf("%v", this.Through) + `,`, `}`, }, "") return s @@ -14253,6 +14282,44 @@ func (m *VolumeResponse) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + m.From = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.From |= github_com_prometheus_common_model.Time(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Through", wireType) + } + m.Through = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLogproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Through |= github_com_prometheus_common_model.Time(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipLogproto(dAtA[iNdEx:]) diff --git a/pkg/logproto/logproto.proto b/pkg/logproto/logproto.proto index 23843a8f8e..41646f4682 100644 --- a/pkg/logproto/logproto.proto +++ b/pkg/logproto/logproto.proto @@ -397,6 +397,14 @@ message VolumeRequest { message VolumeResponse { repeated Volume volumes = 1 [(gogoproto.nullable) = false]; int32 limit = 2; + int64 from = 3 [ + (gogoproto.customtype) = "github.com/prometheus/common/model.Time", + (gogoproto.nullable) = false + ]; + int64 through = 4 [ + (gogoproto.customtype) = "github.com/prometheus/common/model.Time", + (gogoproto.nullable) = false + ]; } message Volume { diff --git a/pkg/querier/http_test.go b/pkg/querier/http_test.go index 302c0bfd99..57ca99dd66 100644 --- a/pkg/querier/http_test.go +++ b/pkg/querier/http_test.go @@ -199,10 +199,18 @@ func TestQueryWrapperMiddleware(t *testing.T) { } func TestSeriesVolumeHandler(t *testing.T) { + now := time.Now() + t1 := model.TimeFromUnix(now.Add(-time.Hour).Unix()) + t2 := model.TimeFromUnix(now.Add(-time.Minute).Unix()) + t.Run("it returns label volumes from the querier", func(t *testing.T) { - ret := &logproto.VolumeResponse{Volumes: []logproto.Volume{ - {Name: "foo", Value: "bar", Volume: 38}, - }} + ret := &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + {Name: `{foo="bar"}`, Value: "", Volume: 38}, + }, + From: t1, + Through: t2, + } querier := newQuerierMock() querier.On("SeriesVolume", mock.Anything, mock.Anything).Return(ret, nil) @@ -225,7 +233,14 @@ func TestSeriesVolumeHandler(t *testing.T) { Limit: 100, }, calls[0].Arguments[1]) - require.Equal(t, strings.TrimSpace(w.Body.String()), `{"volumes":[{"name":"foo","value":"bar","volume":38}]}`) + require.Equal( + t, + fmt.Sprintf( + `{"volumes":[{"name":"{foo=\"bar\"}","value":"","volume":38}],"from":%s,"through":%s}`, + t1, t2, + ), + strings.TrimSpace(w.Body.String()), + ) require.Equal(t, http.StatusOK, w.Result().StatusCode) }) @@ -245,7 +260,7 @@ func TestSeriesVolumeHandler(t *testing.T) { calls := querier.GetMockedCallsByMethod("SeriesVolume") require.Len(t, calls, 1) - require.Equal(t, strings.TrimSpace(w.Body.String()), `{"volumes":[]}`) + require.Equal(t, strings.TrimSpace(w.Body.String()), `{"volumes":[],"from":0,"through":0}`) require.Equal(t, http.StatusOK, w.Result().StatusCode) }) diff --git a/pkg/querier/queryrange/codec.go b/pkg/querier/queryrange/codec.go index 73b513bae2..fe01f4098a 100644 --- a/pkg/querier/queryrange/codec.go +++ b/pkg/querier/queryrange/codec.go @@ -28,6 +28,7 @@ import ( "github.com/grafana/loki/pkg/logqlmodel" "github.com/grafana/loki/pkg/logqlmodel/stats" "github.com/grafana/loki/pkg/querier/queryrange/queryrangebase" + "github.com/grafana/loki/pkg/querier/queryrange/queryrangebase/definitions" indexStats "github.com/grafana/loki/pkg/storage/stores/index/stats" "github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util/httpreq" @@ -744,23 +745,84 @@ func (Codec) MergeResponse(responses ...queryrangebase.Response) (queryrangebase }, nil case *VolumeResponse: resp0 := responses[0].(*VolumeResponse) - headers := resp0.Headers + headers := make([]*definitions.PrometheusResponseHeader, len(resp0.Headers)) + for i, header := range resp0.Headers { + h := header + headers[i] = &h + } resps := make([]*logproto.VolumeResponse, 0, len(responses)) for _, r := range responses { resps = append(resps, r.(*VolumeResponse).Response) } - return &VolumeResponse{ - Response: seriesvolume.Merge(resps, resp0.Response.Limit), - Headers: headers, - }, nil + promResponse := queryrangebase.PrometheusResponse{ + Status: loghttp.QueryStatusSuccess, + Data: MergeToPrometheusResponse(resps, resp0.Response.Limit), + Headers: headers, + } + return &LokiPromResponse{ + Response: &promResponse, + Statistics: stats.Result{}, + }, nil default: return nil, errors.New("unknown response in merging responses") } } +func MergeToPrometheusResponse(responses []*logproto.VolumeResponse, limit int32) queryrangebase.PrometheusData { + mergedVolumes := seriesvolume.Merge(responses, limit) + return mapToPrometheusResponse(mergedVolumes) +} + +func mapToPrometheusResponse(mergedResponse *logproto.VolumeResponse) queryrangebase.PrometheusData { + samplesByStream := map[string]*logproto.LegacySample{} + + // since this is an instant response, we're only interested in a single "bucket", which is + // bounded by the latest timestamp we've seen (which should correspond to the end of the query range) + tsMs := mergedResponse.Through.UnixNano() / 1e6 //convert ns to ms + + // Aggregate samples into single sample with latest timestamp + for _, volume := range mergedResponse.Volumes { + if _, ok := samplesByStream[volume.Name]; !ok { + samplesByStream[volume.Name] = &logproto.LegacySample{ + TimestampMs: tsMs, + } + } + + samplesByStream[volume.Name].Value += float64(volume.Volume) + } + + result := make([]queryrangebase.SampleStream, 0, len(samplesByStream)) + for stream, sample := range samplesByStream { + lbls, err := syntax.ParseLabels(stream) + if err != nil { + continue + } + result = append(result, queryrangebase.SampleStream{ + Labels: logproto.FromLabelsToLabelAdapters(lbls), + Samples: []logproto.LegacySample{*sample}, + }) + } + + // sort to enusre consistent ordering in results + // this only works because all samples in this result set have the same timestamp + // and each sample stream only has a single sample. + sort.Slice(result, func(i, j int) bool { + if result[i].Samples[0].Value == result[j].Samples[0].Value { + return result[i].Labels[0].Name < result[j].Labels[0].Name + } + + return result[i].Samples[0].Value > result[j].Samples[0].Value + }) + + return queryrangebase.PrometheusData{ + ResultType: loghttp.ResultTypeVector, + Result: result, + } +} + // mergeOrderedNonOverlappingStreams merges a set of ordered, nonoverlapping responses by concatenating matching streams then running them through a heap to pull out limit values func mergeOrderedNonOverlappingStreams(resps []*LokiResponse, limit uint32, direction logproto.Direction) []logproto.Stream { var total int diff --git a/pkg/querier/queryrange/codec_test.go b/pkg/querier/queryrange/codec_test.go index b2679f8fdc..c1315a8e3f 100644 --- a/pkg/querier/queryrange/codec_test.go +++ b/pkg/querier/queryrange/codec_test.go @@ -265,7 +265,7 @@ func Test_codec_DecodeResponse(t *testing.T) { &VolumeResponse{ Response: &logproto.VolumeResponse{ Volumes: []logproto.Volume{ - {Name: "foo", Value: "bar", Volume: 38}, + {Name: `{foo="bar"}`, Value: "", Volume: 38}, }, Limit: 100, }, @@ -522,9 +522,11 @@ func Test_codec_EncodeResponse(t *testing.T) { &VolumeResponse{ Response: &logproto.VolumeResponse{ Volumes: []logproto.Volume{ - {Name: "foo", Value: "bar", Volume: 38}, + {Name: `{foo="bar"}`, Value: "", Volume: 38}, }, - Limit: 100, + Limit: 100, + From: 0, + Through: 0, }, }, labelVolumeString, false, }, @@ -1012,6 +1014,184 @@ func Test_codec_MergeResponse(t *testing.T) { } } +func Test_codec_MergeResponse_Volume(t *testing.T) { + now := time.Now() + from := model.TimeFromUnix(now.Add(-time.Hour).Unix()) + through := model.TimeFromUnix(now.Add(-time.Minute).Unix()) + + t.Run("converts to prometheus response, merging results for the same timestamp", func(t *testing.T) { + responses := []queryrangebase.Response{ + &VolumeResponse{ + Response: &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: `{job="prometheus"}`, + Value: "", + Volume: 150, + }, + { + Name: `{job="loki"}`, + Value: "", + Volume: 300, + }, + }, + From: from, + Through: through, + Limit: 5, + }, + }, + &VolumeResponse{ + Response: &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: `{job="prometheus"}`, + Value: "", + Volume: 100, + }, + { + Name: `{job="loki"}`, + Value: "", + Volume: 200, + }, + }, + From: from, + Through: through, + Limit: 5, + }, + }, + } + + got, err := LokiCodec.MergeResponse(responses...) + require.NoError(t, err) + + expected := got.(*LokiPromResponse).Response + + require.Equal(t, expected.Status, "success") + require.Equal(t, expected.Data.ResultType, "vector") + + require.Len(t, expected.Data.Result, 2) + require.Equal(t, expected.Data.Result, []queryrangebase.SampleStream{{ + Labels: []logproto.LabelAdapter{{Name: "job", Value: "loki"}}, + Samples: []logproto.LegacySample{{Value: 500, TimestampMs: through.Unix() * 1e3}}, + }, { + Labels: []logproto.LabelAdapter{{Name: "job", Value: "prometheus"}}, + Samples: []logproto.LegacySample{{Value: 250, TimestampMs: through.Unix() * 1e3}}, + }}) + }) + + t.Run("converts to prometheus response, aggregating all samples per series into the latest timestamp", func(t *testing.T) { + responses := []queryrangebase.Response{ + &VolumeResponse{ + Response: &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: `{job="prometheus"}`, + Value: "", + Volume: 150, + }, + { + Name: `{job="loki"}`, + Value: "", + Volume: 300, + }, + }, + From: from, + Through: through, + Limit: 5, + }, + }, + &VolumeResponse{ + Response: &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: `{job="prometheus"}`, + Value: "", + Volume: 100, + }, + { + Name: `{job="loki"}`, + Value: "", + Volume: 200, + }, + }, + From: from, + Through: through, + Limit: 5, + }, + }, + } + + got, err := LokiCodec.MergeResponse(responses...) + require.NoError(t, err) + + expected := got.(*LokiPromResponse).Response + + require.Len(t, expected.Data.Result, 2) + require.Contains(t, expected.Data.Result, queryrangebase.SampleStream{ + Labels: []logproto.LabelAdapter{{Name: "job", Value: "prometheus"}}, + Samples: []logproto.LegacySample{{Value: 250, TimestampMs: through.Unix() * 1e3}}, + }) + require.Contains(t, expected.Data.Result, queryrangebase.SampleStream{ + Labels: []logproto.LabelAdapter{{Name: "job", Value: "loki"}}, + Samples: []logproto.LegacySample{{Value: 500, TimestampMs: through.Unix() * 1e3}}, + }) + }) + + t.Run("limits number of series return to limit parameter", func(t *testing.T) { + responses := []queryrangebase.Response{ + &VolumeResponse{ + Response: &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: `{job="prometheus"}`, + Value: "", + Volume: 150, + }, + { + Name: `{cluster="dev"}`, + Value: "", + Volume: 300, + }, + }, + From: from, + Through: through, + Limit: 1, + }, + }, + &VolumeResponse{ + Response: &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: `{job="prometheus"}`, + Value: "", + Volume: 100, + }, + { + Name: `{cluster="dev"}`, + Value: "", + Volume: 200, + }, + }, + From: from, + Through: through, + Limit: 1, + }, + }, + } + + got, err := LokiCodec.MergeResponse(responses...) + require.NoError(t, err) + + castedGot := got.(*LokiPromResponse).Response + + require.Len(t, castedGot.Data.Result, 1) + require.Equal(t, queryrangebase.SampleStream{ + Labels: []logproto.LabelAdapter{{Name: "cluster", Value: "dev"}}, + Samples: []logproto.LegacySample{{Value: 500, TimestampMs: through.Unix() * 1e3}}, + }, castedGot.Data.Result[0]) + }) +} + type badResponse struct{} func (badResponse) Reset() {} @@ -1249,15 +1429,17 @@ var ( "entries": 4 }` labelVolumeString = `{ - "volumes": [ - { - "name": "foo", - "value": "bar", - "volume": 38 - } - ], - "limit": 100 - }` + "from": 0, + "limit": 100, + "through": 0, + "volumes": [ + { + "name": "{foo=\"bar\"}", + "value": "", + "volume": 38 + } + ] + }` labelsData = []string{"foo", "bar"} statsResult = stats.Result{ Summary: stats.Summary{ diff --git a/pkg/querier/queryrange/roundtrip_test.go b/pkg/querier/queryrange/roundtrip_test.go index 5eb9928e89..a55204d3cf 100644 --- a/pkg/querier/queryrange/roundtrip_test.go +++ b/pkg/querier/queryrange/roundtrip_test.go @@ -24,6 +24,7 @@ import ( "github.com/weaveworks/common/middleware" "github.com/weaveworks/common/user" + "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/logqlmodel" @@ -134,7 +135,9 @@ var ( {Name: `{foo="bar"}`, Value: "", Volume: 1024}, {Name: `{bar="baz"}`, Value: "", Volume: 3350}, }, - Limit: 10, + From: model.TimeFromUnix(testTime.Add(-4 * time.Hour).Unix()), + Through: model.TimeFromUnix(testTime.Add(-1 * time.Hour).Unix()), + Limit: 5, } ) @@ -580,19 +583,39 @@ func TestSeriesVolumeTripperware(t *testing.T) { require.NoError(t, err) require.Equal(t, 2, *count) // 2 queries from splitting - volumeResp, err := LokiCodec.DecodeResponse(ctx, resp, lreq) + volumeResp, err := LokiCodec.DecodeResponse(ctx, resp, nil) require.NoError(t, err) - expected := logproto.VolumeResponse{ - Volumes: []logproto.Volume{ // add volumes from across shards - {Name: `{bar="baz"}`, Value: "", Volume: 6700}, - {Name: `{foo="bar"}`, Value: "", Volume: 2048}, + expected := queryrangebase.PrometheusData{ + ResultType: loghttp.ResultTypeVector, + Result: []queryrangebase.SampleStream{ + { + Labels: []logproto.LabelAdapter{{ + Name: "bar", + Value: "baz", + }}, + Samples: []logproto.LegacySample{{ + Value: 6700, + TimestampMs: testTime.Add(-1*time.Hour).Unix() * 1e3, + }}, + }, + { + Labels: []logproto.LabelAdapter{{ + Name: "foo", + Value: "bar", + }}, + Samples: []logproto.LegacySample{{ + Value: 2048, + TimestampMs: testTime.Add(-1*time.Hour).Unix() * 1e3, + }}, + }, }, } - res, ok := volumeResp.(*VolumeResponse) + res, ok := volumeResp.(*LokiPromResponse) require.Equal(t, true, ok) - require.Equal(t, expected.Volumes, res.Response.Volumes) + require.Equal(t, "success", res.Response.Status) + require.Equal(t, expected, res.Response.Data) } func TestNewTripperware_Caches(t *testing.T) { diff --git a/pkg/querier/queryrange/split_by_interval.go b/pkg/querier/queryrange/split_by_interval.go index d1a1bd4a1d..41c6d960d5 100644 --- a/pkg/querier/queryrange/split_by_interval.go +++ b/pkg/querier/queryrange/split_by_interval.go @@ -200,7 +200,10 @@ func (h *splitByInterval) Do(ctx context.Context, r queryrangebase.Request) (que sp.LogFields(otlog.Int("n_intervals", len(intervals))) } - if len(intervals) == 1 { + // We always need to merge VolumeRequests as that's how they get turned into + // Prometheus style metric responses. For all other types we can skip merging + // if there is only one interval. + if _, ok := r.(*logproto.VolumeRequest); len(intervals) == 1 && !ok { return h.next.Do(ctx, intervals[0]) } diff --git a/pkg/querier/queryrange/split_by_interval_test.go b/pkg/querier/queryrange/split_by_interval_test.go index 83ce5eb7b0..4215906aa9 100644 --- a/pkg/querier/queryrange/split_by_interval_test.go +++ b/pkg/querier/queryrange/split_by_interval_test.go @@ -853,59 +853,95 @@ func Test_series_splitByInterval_Do(t *testing.T) { func Test_seriesvolume_splitByInterval_Do(t *testing.T) { ctx := user.InjectOrgID(context.Background(), "1") - next := queryrangebase.HandlerFunc(func(_ context.Context, r queryrangebase.Request) (queryrangebase.Response, error) { - return &VolumeResponse{ - Response: &logproto.VolumeResponse{ - Volumes: []logproto.Volume{ - {Name: `{foo="bar"}`, Value: "", Volume: 38}, - {Name: `{bar="baz"}`, Value: "", Volume: 28}, - }, - Limit: 1}, - Headers: nil, - }, nil - }) + setup := func(next queryrangebase.Handler) queryrangebase.Handler { + l := WithSplitByLimits(fakeLimits{maxQueryParallelism: 1}, time.Hour) + return SplitByIntervalMiddleware( + testSchemas, + l, + LokiCodec, + splitByTime, + nilMetrics, + ).Wrap(next) + } - l := WithSplitByLimits(fakeLimits{maxQueryParallelism: 1}, time.Hour) - split := SplitByIntervalMiddleware( - testSchemas, - l, - LokiCodec, - splitByTime, - nilMetrics, - ).Wrap(next) + t.Run("label volumes", func(t *testing.T) { + from := model.TimeFromUnixNano(start.UnixNano()) + through := model.TimeFromUnixNano(end.UnixNano()) - tests := []struct { - name string - req *logproto.VolumeRequest - want *VolumeResponse - }{ - { - "label volumes", - &logproto.VolumeRequest{ - From: model.TimeFromUnixNano(start.UnixNano()), - Through: model.TimeFromUnixNano(end.UnixNano()), - Matchers: "{}", - Limit: 1, - }, - &VolumeResponse{ + next := queryrangebase.HandlerFunc(func(_ context.Context, r queryrangebase.Request) (queryrangebase.Response, error) { + return &VolumeResponse{ Response: &logproto.VolumeResponse{ Volumes: []logproto.Volume{ - {Name: `{foo="bar"}`, Value: "", Volume: 76}, + {Name: `{foo="bar"}`, Value: "", Volume: 38}, + {Name: `{bar="baz"}`, Value: "", Volume: 28}, }, - Limit: 1, - }, + From: from, + Through: through, + Limit: 2}, Headers: nil, - }, - }, - } + }, nil + }) + split := setup(next) + req := &logproto.VolumeRequest{ + From: from, + Through: through, + Matchers: "{}", + Limit: 2, + } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - res, err := split.Do(ctx, tt.req) - require.NoError(t, err) - require.Equal(t, tt.want, res) + res, err := split.Do(ctx, req) + require.NoError(t, err) + + response := res.(*LokiPromResponse) + + require.Len(t, response.Response.Data.Result, 2) + require.Contains(t, response.Response.Data.Result, queryrangebase.SampleStream{ + Labels: []logproto.LabelAdapter{{Name: "foo", Value: "bar"}}, + Samples: []logproto.LegacySample{{TimestampMs: end.Unix() * 1e3, Value: 76}}, }) - } + require.Contains(t, response.Response.Data.Result, queryrangebase.SampleStream{ + Labels: []logproto.LabelAdapter{{Name: "bar", Value: "baz"}}, + Samples: []logproto.LegacySample{{TimestampMs: end.Unix() * 1e3, Value: 56}}, + }) + }) + + t.Run("label volumes with limits", func(t *testing.T) { + from := model.TimeFromUnixNano(start.UnixNano()) + through := model.TimeFromUnixNano(end.UnixNano()) + next := queryrangebase.HandlerFunc(func(_ context.Context, r queryrangebase.Request) (queryrangebase.Response, error) { + return &VolumeResponse{ + Response: &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + {Name: `{foo="bar"}`, Value: "", Volume: 38}, + {Name: `{bar="baz"}`, Value: "", Volume: 28}, + {Name: `{foo="bar"}`, Value: "", Volume: 38}, + {Name: `{fizz="buzz"}`, Value: "", Volume: 28}, + }, + From: from, + Through: through, + Limit: 1}, + Headers: nil, + }, nil + }) + split := setup(next) + req := &logproto.VolumeRequest{ + From: from, + Through: through, + Matchers: "{}", + Limit: 1, + } + + res, err := split.Do(ctx, req) + require.NoError(t, err) + + response := res.(*LokiPromResponse) + + require.Len(t, response.Response.Data.Result, 1) + require.Contains(t, response.Response.Data.Result, queryrangebase.SampleStream{ + Labels: []logproto.LabelAdapter{{Name: "foo", Value: "bar"}}, + Samples: []logproto.LegacySample{{TimestampMs: end.Unix() * 1e3, Value: 152}}, + }) + }) } func Test_ExitEarly(t *testing.T) { diff --git a/pkg/storage/stores/index/seriesvolume/volume.go b/pkg/storage/stores/index/seriesvolume/volume.go index 70552c6e87..20143ee62e 100644 --- a/pkg/storage/stores/index/seriesvolume/volume.go +++ b/pkg/storage/stores/index/seriesvolume/volume.go @@ -3,6 +3,9 @@ package seriesvolume import ( "sort" "sync" + "time" + + "github.com/prometheus/common/model" "github.com/grafana/loki/pkg/logproto" ) @@ -35,15 +38,16 @@ func (acc *Accumulator) AddVolumes(volumes map[string]uint64) { } } -func (acc *Accumulator) Volumes() *logproto.VolumeResponse { +func (acc *Accumulator) Volumes(from, through time.Time) *logproto.VolumeResponse { acc.lock.RLock() defer acc.lock.RUnlock() - return MapToSeriesVolumeResponse(acc.volumes, int(acc.limit)) + return MapToSeriesVolumeResponse(acc.volumes, int(acc.limit), from, through) } func Merge(responses []*logproto.VolumeResponse, limit int32) *logproto.VolumeResponse { mergedVolumes := make(map[string]uint64) + var from, through time.Time for _, res := range responses { if res == nil { @@ -51,15 +55,26 @@ func Merge(responses []*logproto.VolumeResponse, limit int32) *logproto.VolumeRe continue } + resFrom, resThrough := res.From.Time(), res.Through.Time() + + if resFrom.Before(from) || from.IsZero() { + from = resFrom + } + + if resThrough.After(through) || through.IsZero() { + through = resThrough + } + for _, v := range res.Volumes { mergedVolumes[v.Name] += v.GetVolume() + } } - return MapToSeriesVolumeResponse(mergedVolumes, int(limit)) + return MapToSeriesVolumeResponse(mergedVolumes, int(limit), from, through) } -func MapToSeriesVolumeResponse(mergedVolumes map[string]uint64, limit int) *logproto.VolumeResponse { +func MapToSeriesVolumeResponse(mergedVolumes map[string]uint64, limit int, from, through time.Time) *logproto.VolumeResponse { volumes := make([]logproto.Volume, 0, len(mergedVolumes)) for name, size := range mergedVolumes { volumes = append(volumes, logproto.Volume{ @@ -88,5 +103,7 @@ func MapToSeriesVolumeResponse(mergedVolumes map[string]uint64, limit int) *logp return &logproto.VolumeResponse{ Volumes: volumes, Limit: int32(limit), + From: model.TimeFromUnixNano(from.UnixNano()), + Through: model.TimeFromUnixNano(through.UnixNano()), } } diff --git a/pkg/storage/stores/index/seriesvolume/volume_test.go b/pkg/storage/stores/index/seriesvolume/volume_test.go new file mode 100644 index 0000000000..7f86c81d90 --- /dev/null +++ b/pkg/storage/stores/index/seriesvolume/volume_test.go @@ -0,0 +1,361 @@ +package seriesvolume + +import ( + "testing" + "time" + + "github.com/prometheus/common/model" + "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" +) + +func Test_AddVolumes(t *testing.T) { + now := time.Now() + t1 := now.Add(-time.Hour) + t2 := now.Add(-time.Minute) + volumes := map[string]uint64{ + `{job: "loki"}`: 5, + `{job: "prometheus"}`: 10, + `{cluster: "dev"}`: 25, + `{cluster: "prod"}`: 50, + } + + t.Run("accumulates values for the same series", func(t *testing.T) { + acc := NewAccumulator(4) + acc.AddVolumes(volumes) + + resp := acc.Volumes(t1, t2) + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{job: \"prometheus\"}", + Value: "", + Volume: 10, + }, + { + Name: "{job: \"loki\"}", + Value: "", + Volume: 5, + }, + }, + Limit: 4, + From: model.TimeFromUnixNano(t1.UnixNano()), + Through: model.TimeFromUnixNano(t2.UnixNano()), + }, resp) + + acc.AddVolumes(volumes) + + resp = acc.Volumes(t1, t2) + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 100, + }, + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 50, + }, + { + Name: "{job: \"prometheus\"}", + Value: "", + Volume: 20, + }, + { + Name: "{job: \"loki\"}", + Value: "", + Volume: 10, + }, + }, + Limit: 4, + From: model.TimeFromUnixNano(t1.UnixNano()), + Through: model.TimeFromUnixNano(t2.UnixNano()), + }, resp) + }) + + t.Run("sorts label value pairs by volume", func(t *testing.T) { + acc := NewAccumulator(5) + acc.AddVolumes(volumes) + + resp := acc.Volumes(t1, t2) + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{job: \"prometheus\"}", + Value: "", + Volume: 10, + }, + { + Name: "{job: \"loki\"}", + Value: "", + Volume: 5, + }, + }, + Limit: 5, + From: model.TimeFromUnixNano(t1.UnixNano()), + Through: model.TimeFromUnixNano(t2.UnixNano()), + }, resp) + }) + + t.Run("applies limit", func(t *testing.T) { + acc := NewAccumulator(2) + volumes := map[string]uint64{ + `{job: "loki"}`: 5, + `{job: "prometheus"}`: 10, + `{job: "mimir"}`: 1, + } + acc.AddVolumes(volumes) + + volumes = map[string]uint64{ + `{job: "loki"}`: 20, + `{job: "prometheus"}`: 30, + `{job: "mimir"}`: 1, + } + acc.AddVolumes(volumes) + + resp := acc.Volumes(t1, t2) + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: "{job: \"prometheus\"}", + Value: "", + Volume: 40, + }, + { + Name: "{job: \"loki\"}", + Value: "", + Volume: 25, + }, + }, + Limit: 2, + From: model.TimeFromUnixNano(t1.UnixNano()), + Through: model.TimeFromUnixNano(t2.UnixNano()), + }, resp) + }) +} + +func Test_Merge(t *testing.T) { + t.Run("merges and sorts multiple volume responses into a single response with values aggregated", func(t *testing.T) { + limit := int32(5) + responses := []*logproto.VolumeResponse{ + { + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + }, + Limit: limit, + }, + { + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{job: \"foo\"}", + Value: "", + Volume: 15, + }, + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + }, + Limit: limit, + }, + } + + mergedResponse := Merge(responses, limit) + + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 100, + }, + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 50, + }, + { + Name: "{job: \"foo\"}", + Value: "", + Volume: 15, + }, + }, + Limit: limit, + From: 0, + Through: 0, + }, mergedResponse) + }) + + t.Run("applies limit to return N biggest series", func(t *testing.T) { + limit := int32(2) + responses := []*logproto.VolumeResponse{ + { + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + }, + Limit: limit, + }, + { + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{job: \"foo\"}", + Value: "", + Volume: 15, + }, + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + }, + Limit: limit, + }, + } + + mergedResponse := Merge(responses, limit) + + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 100, + }, + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 50, + }, + }, + Limit: limit, + From: 0, + Through: 0, + }, mergedResponse) + }) + + t.Run("aggregates responses into earliest from and latest through timestamp of input", func(t *testing.T) { + limit := int32(5) + now := time.Now() + oneHourFromNow := now.Add(time.Hour) + oneHourAgo := now.Add(-time.Hour) + + responses := []*logproto.VolumeResponse{ + { + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + }, + Limit: limit, + From: 5, + Through: model.TimeFromUnixNano(oneHourAgo.UnixNano()), + }, + { + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 25, + }, + { + Name: "{job: \"foo\"}", + Value: "", + Volume: 15, + }, + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 50, + }, + }, + Limit: limit, + From: 10, + Through: model.TimeFromUnixNano(oneHourFromNow.UnixNano()), + }, + } + + mergedResponse := Merge(responses, limit) + + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + { + Name: "{cluster: \"prod\"}", + Value: "", + Volume: 100, + }, + { + Name: "{cluster: \"dev\"}", + Value: "", + Volume: 50, + }, + { + Name: "{job: \"foo\"}", + Value: "", + Volume: 15, + }, + }, + Limit: limit, + From: 5, + Through: model.TimeFromUnixNano(oneHourFromNow.UnixNano()), + }, mergedResponse) + }) +} diff --git a/pkg/storage/stores/tsdb/index_client.go b/pkg/storage/stores/tsdb/index_client.go index 26c4b8f279..746888e10a 100644 --- a/pkg/storage/stores/tsdb/index_client.go +++ b/pkg/storage/stores/tsdb/index_client.go @@ -49,7 +49,7 @@ type IndexStatsAccumulator interface { type SeriesVolumeAccumulator interface { AddVolumes(map[string]uint64) - Volumes() *logproto.VolumeResponse + Volumes(from, through time.Time) *logproto.VolumeResponse } func NewIndexClient(idx Index, opts IndexClientOptions) *IndexClient { @@ -278,7 +278,7 @@ func (c *IndexClient) SeriesVolume(ctx context.Context, userID string, from, thr return nil, err } - return acc.Volumes(), nil + return acc.Volumes(from.Time(), through.Time()), nil } // SetChunkFilterer sets a chunk filter to be used when retrieving chunks. diff --git a/pkg/storage/stores/tsdb/index_client_test.go b/pkg/storage/stores/tsdb/index_client_test.go index 74c4853d72..eb530d972a 100644 --- a/pkg/storage/stores/tsdb/index_client_test.go +++ b/pkg/storage/stores/tsdb/index_client_test.go @@ -271,9 +271,11 @@ func TestIndexClient_SeriesVolume(t *testing.T) { }) indexClient := NewIndexClient(idx, IndexClientOptions{UseBloomFilters: true}) + from := indexStartYesterday + through := indexStartToday + 1000 t.Run("it returns series volumes from the whole index", func(t *testing.T) { - vol, err := indexClient.SeriesVolume(context.Background(), "", indexStartYesterday, indexStartToday+1000, 10, nil...) + vol, err := indexClient.SeriesVolume(context.Background(), "", from, through, 10, nil...) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ @@ -283,17 +285,23 @@ func TestIndexClient_SeriesVolume(t *testing.T) { {Name: `{fizz="buzz"}`, Value: "", Volume: 100 * 1024}, {Name: `{ping="pong"}`, Value: "", Volume: 100 * 1024}, }, - Limit: 10}, vol) + Limit: 10, + From: from, + Through: through, + }, vol) }) t.Run("it returns largest series from the index", func(t *testing.T) { - vol, err := indexClient.SeriesVolume(context.Background(), "", indexStartYesterday, indexStartToday+1000, 1, nil...) + vol, err := indexClient.SeriesVolume(context.Background(), "", from, through, 1, nil...) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ Volumes: []logproto.Volume{ {Name: `{foo="bar"}`, Value: "", Volume: 200 * 1024}, }, - Limit: 1}, vol) + Limit: 1, + From: from, + Through: through, + }, vol) }) } diff --git a/pkg/storage/stores/tsdb/single_file_index.go b/pkg/storage/stores/tsdb/single_file_index.go index 6c1b020017..fe42e397d2 100644 --- a/pkg/storage/stores/tsdb/single_file_index.go +++ b/pkg/storage/stores/tsdb/single_file_index.go @@ -392,7 +392,6 @@ func (i *TSDBIndex) SeriesVolume(ctx context.Context, _ string, from, through mo if err != nil { return err } - acc.AddVolumes(volumes) return nil } diff --git a/pkg/storage/stores/tsdb/single_file_index_test.go b/pkg/storage/stores/tsdb/single_file_index_test.go index 3ce0e3e98f..08b2537527 100644 --- a/pkg/storage/stores/tsdb/single_file_index_test.go +++ b/pkg/storage/stores/tsdb/single_file_index_test.go @@ -371,21 +371,25 @@ func TestTSDBIndex_Stats(t *testing.T) { } func TestTSDBIndex_SeriesVolume(t *testing.T) { + now := time.Now() + t1 := now.Add(-time.Hour) + t2 := now.Add(-time.Minute) + series := []LoadableSeries{ { Labels: mustParseLabels(`{foo="bar", fizz="buzz", __loki_tenant__="fake"}`), Chunks: []index.ChunkMeta{ { - MinTime: 0, - MaxTime: 10, + MinTime: t1.UnixMilli(), + MaxTime: t1.Add(30 * time.Minute).UnixMilli(), Checksum: 1, Entries: 10, KB: 10, }, { - MinTime: 10, - MaxTime: 20, + MinTime: t1.Add(30 * time.Minute).UnixMilli(), + MaxTime: t2.UnixMilli(), Checksum: 2, Entries: 20, KB: 20, @@ -396,15 +400,15 @@ func TestTSDBIndex_SeriesVolume(t *testing.T) { Labels: mustParseLabels(`{foo="bar", fizz="fizz", __loki_tenant__="fake"}`), Chunks: []index.ChunkMeta{ { - MinTime: 0, - MaxTime: 10, + MinTime: t1.UnixMilli(), + MaxTime: t1.Add(30 * time.Minute).UnixMilli(), Checksum: 3, Entries: 30, KB: 30, }, { - MinTime: 10, - MaxTime: 20, + MinTime: t1.Add(30 * time.Minute).UnixMilli(), + MaxTime: t2.UnixMilli(), Checksum: 4, Entries: 40, KB: 40, @@ -417,17 +421,23 @@ func TestTSDBIndex_SeriesVolume(t *testing.T) { tempDir := t.TempDir() tsdbIndex := BuildIndex(t, tempDir, series) + from := model.TimeFromUnixNano(t1.UnixNano()) + through := model.TimeFromUnixNano(t2.UnixNano()) + t.Run("it matches all the series when the match all matcher is passed", func(t *testing.T) { matcher := labels.MustNewMatcher(labels.MatchEqual, "", "") acc := seriesvolume.NewAccumulator(10) - err := tsdbIndex.SeriesVolume(context.Background(), "fake", 0, 20, acc, nil, nil, matcher) + err := tsdbIndex.SeriesVolume(context.Background(), "fake", from, through, acc, nil, nil, matcher) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ Volumes: []logproto.Volume{ {Name: `{fizz="fizz", foo="bar"}`, Value: "", Volume: (30 + 40) * 1024}, - {Name: `{fizz="buzz", foo="bar"}`, Volume: (10 + 20) * 1024}, + {Name: `{fizz="buzz", foo="bar"}`, Value: "", Volume: (10 + 20) * 1024}, }, - Limit: 10}, acc.Volumes()) + Limit: 10, + From: from, + Through: through, + }, acc.Volumes(t1, t2)) }) t.Run("it ignores the tenant label matcher", func(t *testing.T) { @@ -436,36 +446,64 @@ func TestTSDBIndex_SeriesVolume(t *testing.T) { labels.MustNewMatcher(labels.MatchRegexp, "foo", ".+"), } acc := seriesvolume.NewAccumulator(10) - err := tsdbIndex.SeriesVolume(context.Background(), "fake", 0, 20, acc, nil, nil, withTenantLabelMatcher("fake", matcher)...) + err := tsdbIndex.SeriesVolume(context.Background(), "fake", from, through, acc, nil, nil, withTenantLabelMatcher("fake", matcher)...) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ Volumes: []logproto.Volume{ {Name: `{fizz="fizz", foo="bar"}`, Value: "", Volume: (30 + 40) * 1024}, - {Name: `{fizz="buzz", foo="bar"}`, Volume: (10 + 20) * 1024}, + {Name: `{fizz="buzz", foo="bar"}`, Value: "", Volume: (10 + 20) * 1024}, }, - Limit: 10}, acc.Volumes()) + Limit: 10, + From: from, + Through: through, + }, acc.Volumes(t1, t2)) }) t.Run("it matches none of the series", func(t *testing.T) { matcher := labels.MustNewMatcher(labels.MatchEqual, "foo", "baz") acc := seriesvolume.NewAccumulator(10) - err := tsdbIndex.SeriesVolume(context.Background(), "fake", 0, 20, acc, nil, nil, matcher) + err := tsdbIndex.SeriesVolume(context.Background(), "fake", from, through, acc, nil, nil, matcher) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ Volumes: []logproto.Volume{}, - Limit: 10}, acc.Volumes()) + Limit: 10, + From: from, + Through: through, + }, acc.Volumes(t1, t2)) }) t.Run("it only returns results for the labels in the matcher", func(t *testing.T) { matcher := labels.MustNewMatcher(labels.MatchEqual, "foo", "bar") acc := seriesvolume.NewAccumulator(10) - err := tsdbIndex.SeriesVolume(context.Background(), "fake", 0, 20, acc, nil, nil, matcher) + err := tsdbIndex.SeriesVolume(context.Background(), "fake", from, through, acc, nil, nil, matcher) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ Volumes: []logproto.Volume{ {Name: `{foo="bar"}`, Value: "", Volume: (10 + 20 + 30 + 40) * 1024}, }, - Limit: 10}, acc.Volumes()) + Limit: 10, + From: from, + Through: through, + }, acc.Volumes(t1, t2)) + }) + + t.Run("it returns results for label names in matchers", func(t *testing.T) { + matchers := []*labels.Matcher{ + labels.MustNewMatcher(labels.MatchEqual, "foo", "bar"), + labels.MustNewMatcher(labels.MatchRegexp, "fizz", ".+"), + } + acc := seriesvolume.NewAccumulator(10) + err := tsdbIndex.SeriesVolume(context.Background(), "fake", from, through, acc, nil, nil, matchers...) + require.NoError(t, err) + require.Equal(t, &logproto.VolumeResponse{ + Volumes: []logproto.Volume{ + {Name: `{fizz="fizz", foo="bar"}`, Value: "", Volume: (30 + 40) * 1024}, + {Name: `{fizz="buzz", foo="bar"}`, Value: "", Volume: (10 + 20) * 1024}, + }, + Limit: 10, + From: from, + Through: through, + }, acc.Volumes(t1, t2)) }) t.Run("it returns results for label names in matchers", func(t *testing.T) { @@ -474,14 +512,17 @@ func TestTSDBIndex_SeriesVolume(t *testing.T) { labels.MustNewMatcher(labels.MatchRegexp, "fizz", ".+"), } acc := seriesvolume.NewAccumulator(10) - err := tsdbIndex.SeriesVolume(context.Background(), "fake", 0, 20, acc, nil, nil, matchers...) + err := tsdbIndex.SeriesVolume(context.Background(), "fake", from, through, acc, nil, nil, matchers...) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ Volumes: []logproto.Volume{ {Name: `{fizz="fizz", foo="bar"}`, Value: "", Volume: (30 + 40) * 1024}, {Name: `{fizz="buzz", foo="bar"}`, Volume: (10 + 20) * 1024}, }, - Limit: 10}, acc.Volumes()) + Limit: 10, + From: from, + Through: through, + }, acc.Volumes(t1, t2)) }) t.Run("it can filter chunks", func(t *testing.T) { @@ -490,12 +531,15 @@ func TestTSDBIndex_SeriesVolume(t *testing.T) { matcher := labels.MustNewMatcher(labels.MatchEqual, "", "") acc := seriesvolume.NewAccumulator(10) - err := tsdbIndex.SeriesVolume(context.Background(), "fake", 0, 20, acc, nil, nil, matcher) + err := tsdbIndex.SeriesVolume(context.Background(), "fake", from, through, acc, nil, nil, matcher) require.NoError(t, err) require.Equal(t, &logproto.VolumeResponse{ Volumes: []logproto.Volume{}, - Limit: 10}, acc.Volumes()) + Limit: 10, + From: from, + Through: through, + }, acc.Volumes(t1, t2)) }) }