diff --git a/CHANGELOG.md b/CHANGELOG.md index b59c04f674..ace48b1a9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## Main +* [5622](https://github.com/grafana/loki/pull/5622) **chaudum**: Fix bug in query splitter that caused `interval` query parameter to be ignored and therefore returning more logs than expected. * [5521](https://github.com/grafana/loki/pull/5521) **cstyan**: Move stream lag configuration to top level clients config struct and refactor stream lag metric, this resolves a bug with duplicate metric collection when a single Promtail binary is running multiple Promtail clients. * [5568](https://github.com/grafana/loki/pull/5568) **afayngelerindbx**: Fix canary panics due to concurrent execution of `confirmMissing` * [5552](https://github.com/grafana/loki/pull/5552) **jiachengxu**: Loki mixin: add `DiskSpaceUtilizationPanel` diff --git a/pkg/querier/queryrange/codec.go b/pkg/querier/queryrange/codec.go index 712997198e..cb5c1acca2 100644 --- a/pkg/querier/queryrange/codec.go +++ b/pkg/querier/queryrange/codec.go @@ -75,6 +75,7 @@ func (r *LokiRequest) LogToSpan(sp opentracing.Span) { otlog.String("start", timestamp.Time(r.GetStart()).String()), otlog.String("end", timestamp.Time(r.GetEnd()).String()), otlog.Int64("step (ms)", r.GetStep()), + otlog.Int64("interval (ms)", r.GetInterval()), otlog.Int64("limit", int64(r.GetLimit())), otlog.String("direction", r.GetDirection().String()), otlog.String("shards", strings.Join(r.GetShards(), ",")), @@ -218,10 +219,10 @@ func (Codec) DecodeRequest(_ context.Context, r *http.Request, forwardHeaders [] Direction: req.Direction, StartTs: req.Start.UTC(), EndTs: req.End.UTC(), - // GetStep must return milliseconds - Step: int64(req.Step) / 1e6, - Path: r.URL.Path, - Shards: req.Shards, + Step: req.Step.Milliseconds(), + Interval: req.Interval.Milliseconds(), + Path: r.URL.Path, + Shards: req.Shards, }, nil case InstantQueryOp: req, err := loghttp.ParseInstantQuery(r) @@ -285,6 +286,9 @@ func (Codec) EncodeRequest(ctx context.Context, r queryrangebase.Request) (*http if request.Step != 0 { params["step"] = []string{fmt.Sprintf("%f", float64(request.Step)/float64(1e3))} } + if request.Interval != 0 { + params["interval"] = []string{fmt.Sprintf("%f", float64(request.Interval)/float64(1e3))} + } u := &url.URL{ // the request could come /api/prom/query but we want to only use the new api. Path: "/loki/api/v1/query_range", @@ -799,7 +803,9 @@ func (p paramsRangeWrapper) End() time.Time { func (p paramsRangeWrapper) Step() time.Duration { return time.Duration(p.GetStep() * 1e6) } -func (p paramsRangeWrapper) Interval() time.Duration { return 0 } +func (p paramsRangeWrapper) Interval() time.Duration { + return time.Duration(p.GetInterval() * 1e6) +} func (p paramsRangeWrapper) Direction() logproto.Direction { return p.GetDirection() } diff --git a/pkg/querier/queryrange/codec_test.go b/pkg/querier/queryrange/codec_test.go index d55bcaaf3e..f61abbafcb 100644 --- a/pkg/querier/queryrange/codec_test.go +++ b/pkg/querier/queryrange/codec_test.go @@ -37,26 +37,27 @@ func Test_codec_DecodeRequest(t *testing.T) { wantErr bool }{ {"wrong", func() (*http.Request, error) { return http.NewRequest(http.MethodGet, "/bad?step=bad", nil) }, nil, true}, - {"ok", func() (*http.Request, error) { + {"query_range", func() (*http.Request, error) { return http.NewRequest(http.MethodGet, - fmt.Sprintf(`/query_range?start=%d&end=%d&query={foo="bar"}&step=1&limit=200&direction=FORWARD`, start.UnixNano(), end.UnixNano()), nil) + fmt.Sprintf(`/query_range?start=%d&end=%d&query={foo="bar"}&step=10&limit=200&direction=FORWARD`, start.UnixNano(), end.UnixNano()), nil) }, &LokiRequest{ Query: `{foo="bar"}`, Limit: 200, - Step: 1000, // step is expected in ms. + Step: 10000, // step is expected in ms Direction: logproto.FORWARD, Path: "/query_range", StartTs: start, EndTs: end, }, false}, - {"ok", func() (*http.Request, error) { + {"query_range", func() (*http.Request, error) { return http.NewRequest(http.MethodGet, - fmt.Sprintf(`/query_range?start=%d&end=%d&query={foo="bar"}&step=86400&limit=200&direction=FORWARD`, start.UnixNano(), end.UnixNano()), nil) + fmt.Sprintf(`/query_range?start=%d&end=%d&query={foo="bar"}&interval=10&limit=200&direction=BACKWARD`, start.UnixNano(), end.UnixNano()), nil) }, &LokiRequest{ Query: `{foo="bar"}`, Limit: 200, - Step: 86400000, // step is expected in ms. - Direction: logproto.FORWARD, + Step: 14000, // step is expected in ms; calculated default if request param not present + Interval: 10000, // interval is expected in ms + Direction: logproto.BACKWARD, Path: "/query_range", StartTs: start, EndTs: end, @@ -222,7 +223,8 @@ func Test_codec_EncodeRequest(t *testing.T) { toEncode := &LokiRequest{ Query: `{foo="bar"}`, Limit: 200, - Step: 86400000, + Step: 86400000, // nanoseconds + Interval: 10000000, // nanoseconds Direction: logproto.FORWARD, Path: "/query_range", StartTs: start, @@ -238,12 +240,14 @@ func Test_codec_EncodeRequest(t *testing.T) { require.Equal(t, fmt.Sprintf("%d", 200), got.URL.Query().Get("limit")) require.Equal(t, `FORWARD`, got.URL.Query().Get("direction")) require.Equal(t, "86400.000000", got.URL.Query().Get("step")) + require.Equal(t, "10000.000000", got.URL.Query().Get("interval")) // testing a full roundtrip req, err := LokiCodec.DecodeRequest(context.TODO(), got, nil) require.NoError(t, err) require.Equal(t, toEncode.Query, req.(*LokiRequest).Query) require.Equal(t, toEncode.Step, req.(*LokiRequest).Step) + require.Equal(t, toEncode.Interval, req.(*LokiRequest).Interval) require.Equal(t, toEncode.StartTs, req.(*LokiRequest).StartTs) require.Equal(t, toEncode.EndTs, req.(*LokiRequest).EndTs) require.Equal(t, toEncode.Direction, req.(*LokiRequest).Direction) diff --git a/pkg/querier/queryrange/downstreamer.go b/pkg/querier/queryrange/downstreamer.go index f4ae9e756d..8e7b184bc2 100644 --- a/pkg/querier/queryrange/downstreamer.go +++ b/pkg/querier/queryrange/downstreamer.go @@ -3,7 +3,6 @@ package queryrange import ( "context" "fmt" - "time" "github.com/go-kit/log/level" "github.com/prometheus/prometheus/model/labels" @@ -26,7 +25,7 @@ type DownstreamHandler struct { } func ParamsToLokiRequest(params logql.Params, shards logql.Shards) queryrangebase.Request { - if params.Start() == params.End() { + if params.Start().Equal(params.End()) { return &LokiInstantRequest{ Query: params.Query(), Limit: params.Limit(), @@ -39,7 +38,8 @@ func ParamsToLokiRequest(params logql.Params, shards logql.Shards) queryrangebas return &LokiRequest{ Query: params.Query(), Limit: params.Limit(), - Step: int64(params.Step() / time.Millisecond), + Step: params.Step().Milliseconds(), + Interval: params.Interval().Milliseconds(), StartTs: params.Start(), EndTs: params.End(), Direction: params.Direction(), diff --git a/pkg/querier/queryrange/queryrange.pb.go b/pkg/querier/queryrange/queryrange.pb.go index d5a92e6eef..8faa96547f 100644 --- a/pkg/querier/queryrange/queryrange.pb.go +++ b/pkg/querier/queryrange/queryrange.pb.go @@ -38,6 +38,7 @@ type LokiRequest struct { Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` Limit uint32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` Step int64 `protobuf:"varint,3,opt,name=step,proto3" json:"step,omitempty"` + Interval int64 `protobuf:"varint,9,opt,name=interval,proto3" json:"interval,omitempty"` StartTs time.Time `protobuf:"bytes,4,opt,name=startTs,proto3,stdtime" json:"startTs"` EndTs time.Time `protobuf:"bytes,5,opt,name=endTs,proto3,stdtime" json:"endTs"` Direction logproto.Direction `protobuf:"varint,6,opt,name=direction,proto3,enum=logproto.Direction" json:"direction,omitempty"` @@ -98,6 +99,13 @@ func (m *LokiRequest) GetStep() int64 { return 0 } +func (m *LokiRequest) GetInterval() int64 { + if m != nil { + return m.Interval + } + return 0 +} + func (m *LokiRequest) GetStartTs() time.Time { if m != nil { return m.StartTs @@ -683,64 +691,65 @@ func init() { } var fileDescriptor_51b9d53b40d11902 = []byte{ - // 905 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x54, 0x4f, 0x6f, 0x23, 0x35, - 0x14, 0x8f, 0xf3, 0xb7, 0x71, 0xd9, 0x02, 0xee, 0xb2, 0x3b, 0x2a, 0xd2, 0x4c, 0x94, 0x03, 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62, 0xfd, 0xae, 0x0e, 0x5f, 0x30, 0x12, - 0x11, 0x19, 0x4b, 0x05, 0x55, 0x49, 0x0f, 0x25, 0x91, 0x53, 0x61, 0x60, 0x16, 0x49, 0xda, 0x83, - 0x8b, 0x1b, 0xf4, 0x31, 0xac, 0xef, 0x11, 0x49, 0x34, 0xe4, 0xcd, 0xdd, 0x9b, 0xbe, 0xa5, 0x4c, - 0xf5, 0x96, 0xba, 0x0b, 0x6e, 0x29, 0x54, 0xf3, 0xdc, 0xdb, 0x1a, 0x13, 0x49, 0xde, 0x62, 0x49, - 0x24, 0x69, 0x92, 0xc9, 0x23, 0xac, 0x33, 0xd1, 0xbb, 0xb0, 0xfd, 0x09, 0xe7, 0x8c, 0x0f, 0x8e, - 0x32, 0xaa, 0x29, 0x6a, 0x07, 0xb7, 0xe7, 0xb9, 0xb7, 0x4d, 0x4b, 0xa7, 0x95, 0xb1, 0x8c, 0x44, - 0x6f, 0xc0, 0x86, 0x36, 0x34, 0x29, 0xed, 0x60, 0x7b, 0x9e, 0x7b, 0x2f, 0xea, 0x14, 0x2b, 0xdc, - 0x44, 0xac, 0x72, 0xd8, 0xb8, 0x12, 0x87, 0x8b, 0x56, 0x36, 0xed, 0x56, 0x3a, 0xb0, 0xf5, 0x35, - 0xe5, 0x42, 0x3d, 0xd3, 0xd2, 0xfe, 0xd2, 0x44, 0xf7, 0x20, 0x54, 0xc4, 0x44, 0x42, 0x46, 0x23, - 0xa5, 0x27, 0x45, 0xc6, 0x0d, 0xdf, 0x4c, 0x36, 0xa6, 0x62, 0x1a, 0xcb, 0x00, 0x15, 0x2c, 0x58, - 0x81, 0xd8, 0x3a, 0xa3, 0xef, 0x01, 0x6c, 0x7d, 0x46, 0xc9, 0x98, 0x72, 0xe1, 0xb4, 0x3b, 0xb5, - 0xde, 0xe6, 0x6e, 0xcf, 0x5f, 0x1d, 0x7b, 0xff, 0x0b, 0xce, 0x12, 0x2a, 0x27, 0x74, 0x2a, 0xca, - 0x1e, 0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, 0xa5, 0xb0, 0x69, 0xac, 0x62, 0x2e, 0x6e, 0x5b, - 0x73, 0x21, 0x39, 0x25, 0xc9, 0xbd, 0x31, 0xc9, 0x24, 0xe5, 0xc1, 0x87, 0xaa, 0x63, 0x4f, 0x72, - 0xef, 0xcd, 0x7f, 0xc3, 0xf4, 0x4c, 0xae, 0x6a, 0x8a, 0xf9, 0x2e, 0x2e, 0xbe, 0xd2, 0xfd, 0x16, - 0xc0, 0x97, 0x54, 0xb1, 0x0a, 0xdb, 0xa2, 0x9b, 0x7b, 0x70, 0x83, 0x17, 0xe7, 0x42, 0x79, 0xdd, - 0xcb, 0x79, 0x0e, 0xea, 0xc7, 0xb9, 0x07, 0xf0, 0x22, 0x13, 0xdd, 0x5d, 0x59, 0xf2, 0xd5, 0xf3, - 0x96, 0xbc, 0x4a, 0xa9, 0xd8, 0x6b, 0x3d, 0x78, 0xe7, 0xe4, 0xd4, 0xad, 0x3c, 0x3e, 0x75, 0x2b, - 0x4f, 0x4f, 0x5d, 0xf0, 0xcd, 0xcc, 0x05, 0x3f, 0xcd, 0x5c, 0x70, 0x3c, 0x73, 0xc1, 0xc9, 0xcc, - 0x05, 0x7f, 0xcc, 0x5c, 0xf0, 0xe7, 0xcc, 0xad, 0x3c, 0x9d, 0xb9, 0xe0, 0xd1, 0x99, 0x5b, 0x39, - 0x39, 0x73, 0x2b, 0x8f, 0xcf, 0xdc, 0xca, 0xb0, 0xa9, 0x51, 0xde, 0xfd, 0x3b, 0x00, 0x00, 0xff, - 0xff, 0x23, 0x71, 0xde, 0xa2, 0xb3, 0x0a, 0x00, 0x00, + // 918 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x54, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0xf8, 0xff, 0x4e, 0x68, 0x80, 0x49, 0x69, 0x57, 0x46, 0xda, 0xb5, 0x7c, 0x00, 0x23, + 0xe8, 0x5a, 0xa4, 0xc0, 0x01, 0x01, 0xa2, 0xab, 0x80, 0xa8, 0x54, 0x21, 0xb4, 0xb5, 0xb8, 0xa2, + 0x71, 0x3c, 0xb1, 0x57, 0xd9, 0xdd, 0xd9, 0xcc, 0x8c, 0x2b, 0xe5, 0xc6, 0x17, 0x40, 0xea, 0x67, + 0x00, 0x24, 0x10, 0x9f, 0x82, 0x63, 0x8e, 0x3e, 0x56, 0x95, 0x58, 0x88, 0x73, 0x01, 0x9f, 0xfa, + 0x11, 0xd0, 0xcc, 0xec, 0xae, 0xc7, 0x25, 0x21, 0x71, 0x73, 0x41, 0x5c, 0xec, 0x79, 0x6f, 0xde, + 0x6f, 0xf6, 0xbd, 0xdf, 0xfb, 0xbd, 0x07, 0xdf, 0x4c, 0x0f, 0x27, 0x83, 0xa3, 0x19, 0x61, 0x21, + 0x61, 0xea, 0xff, 0x98, 0xe1, 0x64, 0x42, 0x8c, 0xa3, 0x97, 0x32, 0x2a, 0x28, 0x82, 0x2b, 0x4f, + 0xe7, 0xce, 0x24, 0x14, 0xd3, 0xd9, 0xc8, 0xdb, 0xa7, 0xf1, 0x60, 0x42, 0x27, 0x74, 0xa0, 0x42, + 0x46, 0xb3, 0x03, 0x65, 0x29, 0x43, 0x9d, 0x34, 0xb4, 0xf3, 0xba, 0xfc, 0x46, 0x44, 0x27, 0xfa, + 0xa2, 0x38, 0xe4, 0x97, 0xdd, 0xfc, 0xf2, 0x28, 0x8a, 0xe9, 0x98, 0x44, 0x03, 0x2e, 0xb0, 0xe0, + 0xfa, 0x37, 0x8f, 0xf8, 0xe0, 0xd2, 0x14, 0x47, 0x98, 0xff, 0x33, 0xe3, 0x8e, 0x3b, 0xa1, 0x74, + 0x12, 0x91, 0x55, 0x72, 0x22, 0x8c, 0x09, 0x17, 0x38, 0x4e, 0x75, 0x40, 0x6f, 0x5e, 0x85, 0x5b, + 0x0f, 0xe8, 0x61, 0x18, 0x90, 0xa3, 0x19, 0xe1, 0x02,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9, 0x96, 0x6b, 0x8d, + 0x95, 0xde, 0xc0, 0x88, 0x40, 0x09, 0x6c, 0x6a, 0x2b, 0x9f, 0x8b, 0xdb, 0xc6, 0x5c, 0x08, 0x46, + 0x70, 0x7c, 0x6f, 0x8c, 0x53, 0x41, 0x98, 0xff, 0xb1, 0xec, 0xd8, 0xd3, 0xcc, 0x7d, 0xfb, 0xdf, + 0x6a, 0x7a, 0x0e, 0x2b, 0x9b, 0xa2, 0xbf, 0x1b, 0xe4, 0x5f, 0xe9, 0x7d, 0x07, 0xe0, 0x2b, 0x32, + 0x59, 0x59, 0x5b, 0xd9, 0xcd, 0x3d, 0xd8, 0x66, 0xf9, 0x39, 0x57, 0x5e, 0xef, 0x72, 0x9e, 0xfd, + 0xfa, 0x49, 0xe6, 0x82, 0xa0, 0x44, 0xa2, 0xbb, 0x6b, 0x4b, 0xbe, 0x7a, 0xde, 0x92, 0x97, 0x90, + 0x8a, 0xb9, 0xd6, 0xfd, 0xf7, 0xe6, 0xa7, 0x4e, 0xe5, 0xc9, 0xa9, 0x53, 0x79, 0x76, 0xea, 0x80, + 0x6f, 0x17, 0x0e, 0xf8, 0x79, 0xe1, 0x80, 0x93, 0x85, 0x03, 0xe6, 0x0b, 0x07, 0xfc, 0xb1, 0x70, + 0xc0, 0x9f, 0x0b, 0xa7, 0xf2, 0x6c, 0xe1, 0x80, 0xc7, 0x67, 0x4e, 0x65, 0x7e, 0xe6, 0x54, 0x9e, + 0x9c, 0x39, 0x95, 0x51, 0x53, 0x55, 0x79, 0xf7, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb2, 0xd3, + 0xfe, 0x78, 0xcf, 0x0a, 0x00, 0x00, } func (this *LokiRequest) Equal(that interface{}) bool { @@ -771,6 +780,9 @@ func (this *LokiRequest) Equal(that interface{}) bool { if this.Step != that1.Step { return false } + if this.Interval != that1.Interval { + return false + } if !this.StartTs.Equal(that1.StartTs) { return false } @@ -1115,11 +1127,12 @@ func (this *LokiRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 12) + s := make([]string, 0, 13) s = append(s, "&queryrange.LokiRequest{") s = append(s, "Query: "+fmt.Sprintf("%#v", this.Query)+",\n") s = append(s, "Limit: "+fmt.Sprintf("%#v", this.Limit)+",\n") s = append(s, "Step: "+fmt.Sprintf("%#v", this.Step)+",\n") + s = append(s, "Interval: "+fmt.Sprintf("%#v", this.Interval)+",\n") s = append(s, "StartTs: "+fmt.Sprintf("%#v", this.StartTs)+",\n") s = append(s, "EndTs: "+fmt.Sprintf("%#v", this.EndTs)+",\n") s = append(s, "Direction: "+fmt.Sprintf("%#v", this.Direction)+",\n") @@ -1271,6 +1284,11 @@ func (m *LokiRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Interval != 0 { + i = encodeVarintQueryrange(dAtA, i, uint64(m.Interval)) + i-- + dAtA[i] = 0x48 + } if len(m.Shards) > 0 { for iNdEx := len(m.Shards) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Shards[iNdEx]) @@ -1849,6 +1867,9 @@ func (m *LokiRequest) Size() (n int) { n += 1 + l + sovQueryrange(uint64(l)) } } + if m.Interval != 0 { + n += 1 + sovQueryrange(uint64(m.Interval)) + } return n } @@ -2078,6 +2099,7 @@ func (this *LokiRequest) String() string { `Direction:` + fmt.Sprintf("%v", this.Direction) + `,`, `Path:` + fmt.Sprintf("%v", this.Path) + `,`, `Shards:` + fmt.Sprintf("%v", this.Shards) + `,`, + `Interval:` + fmt.Sprintf("%v", this.Interval) + `,`, `}`, }, "") return s @@ -2450,6 +2472,25 @@ func (m *LokiRequest) Unmarshal(dAtA []byte) error { } m.Shards = append(m.Shards, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Interval", wireType) + } + m.Interval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQueryrange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Interval |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQueryrange(dAtA[iNdEx:]) diff --git a/pkg/querier/queryrange/queryrange.proto b/pkg/querier/queryrange/queryrange.proto index a28d75b73f..21d47641a2 100644 --- a/pkg/querier/queryrange/queryrange.proto +++ b/pkg/querier/queryrange/queryrange.proto @@ -15,6 +15,7 @@ message LokiRequest { string query = 1; uint32 limit = 2; int64 step = 3; + int64 interval = 9; google.protobuf.Timestamp startTs = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; google.protobuf.Timestamp endTs = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; logproto.Direction direction = 6; diff --git a/pkg/querier/queryrange/split_by_interval.go b/pkg/querier/queryrange/split_by_interval.go index 16c704e24b..cc8a45666e 100644 --- a/pkg/querier/queryrange/split_by_interval.go +++ b/pkg/querier/queryrange/split_by_interval.go @@ -232,6 +232,7 @@ func splitByTime(req queryrangebase.Request, interval time.Duration) ([]queryran Query: r.Query, Limit: r.Limit, Step: r.Step, + Interval: r.Interval, Direction: r.Direction, Path: r.Path, StartTs: start, @@ -348,6 +349,7 @@ func splitMetricByTime(r queryrangebase.Request, interval time.Duration) ([]quer Query: lokiReq.Query, Limit: lokiReq.Limit, Step: lokiReq.Step, + Interval: lokiReq.Interval, Direction: lokiReq.Direction, Path: lokiReq.Path, StartTs: start, @@ -367,6 +369,7 @@ func splitMetricByTime(r queryrangebase.Request, interval time.Duration) ([]quer Query: lokiReq.Query, Limit: lokiReq.Limit, Step: lokiReq.Step, + Interval: lokiReq.Interval, Direction: lokiReq.Direction, Path: lokiReq.Path, StartTs: start, diff --git a/pkg/querier/queryrange/split_by_interval_test.go b/pkg/querier/queryrange/split_by_interval_test.go index a5da3f74b0..a2df38b983 100644 --- a/pkg/querier/queryrange/split_by_interval_test.go +++ b/pkg/querier/queryrange/split_by_interval_test.go @@ -34,6 +34,18 @@ func Test_splitQuery(t *testing.T) { } } + buildLokiRequestWithInterval := func(start, end time.Time) queryrangebase.Request { + return &LokiRequest{ + Query: "foo", + Limit: 1, + Interval: 2, + StartTs: start, + EndTs: end, + Direction: logproto.BACKWARD, + Path: "/path", + } + } + buildLokiSeriesRequest := func(start, end time.Time) queryrangebase.Request { return &LokiSeriesRequest{ Match: []string{"match1"}, @@ -63,6 +75,10 @@ func Test_splitQuery(t *testing.T) { buildLokiRequest, false, }, + "LokiRequestWithInterval": { + buildLokiRequestWithInterval, + false, + }, "LokiSeriesRequest": { buildLokiSeriesRequest, true,