@ -342,6 +342,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
start time . Time
end time . Time
step time . Duration
interval time . Duration
direction logproto . Direction
limit uint32
@ -353,7 +354,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
expected promql . Value
} {
{
` { app="foo"} ` , time . Unix ( 0 , 0 ) , time . Unix ( 30 , 0 ) , time . Second , logproto . FORWARD , 10 ,
` { app="foo"} ` , time . Unix ( 0 , 0 ) , time . Unix ( 30 , 0 ) , time . Second , 0 , logproto . FORWARD , 10 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , identity , ` { app="foo"} ` ) } ,
} ,
@ -363,7 +364,27 @@ func TestEngine_NewRangeQuery(t *testing.T) {
Streams ( [ ] * logproto . Stream { newStream ( 10 , identity , ` { app="foo"} ` ) } ) ,
} ,
{
` { app="bar"} |= "foo" |~ ".+bar" ` , time . Unix ( 0 , 0 ) , time . Unix ( 30 , 0 ) , time . Second , logproto . BACKWARD , 30 ,
` { app="food"} ` , time . Unix ( 0 , 0 ) , time . Unix ( 30 , 0 ) , 0 , 2 * time . Second , logproto . FORWARD , 10 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , identity , ` { app="food"} ` ) } ,
} ,
[ ] SelectParams {
{ & logproto . QueryRequest { Direction : logproto . FORWARD , Start : time . Unix ( 0 , 0 ) , End : time . Unix ( 30 , 0 ) , Limit : 10 , Selector : ` { app="food"} ` } } ,
} ,
Streams ( [ ] * logproto . Stream { newIntervalStream ( 10 , 2 * time . Second , identity , ` { app="food"} ` ) } ) ,
} ,
{
` { app="fed"} ` , time . Unix ( 0 , 0 ) , time . Unix ( 30 , 0 ) , 0 , 2 * time . Second , logproto . BACKWARD , 10 ,
[ ] [ ] * logproto . Stream {
{ newBackwardStream ( testSize , identity , ` { app="fed"} ` ) } ,
} ,
[ ] SelectParams {
{ & logproto . QueryRequest { Direction : logproto . BACKWARD , Start : time . Unix ( 0 , 0 ) , End : time . Unix ( 30 , 0 ) , Limit : 10 , Selector : ` { app="fed"} ` } } ,
} ,
Streams ( [ ] * logproto . Stream { newBackwardIntervalStream ( testSize , 10 , 2 * time . Second , identity , ` { app="fed"} ` ) } ) ,
} ,
{
` { app="bar"} |= "foo" |~ ".+bar" ` , time . Unix ( 0 , 0 ) , time . Unix ( 30 , 0 ) , time . Second , 0 , logproto . BACKWARD , 30 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , identity , ` { app="bar"} ` ) } ,
} ,
@ -373,7 +394,17 @@ func TestEngine_NewRangeQuery(t *testing.T) {
Streams ( [ ] * logproto . Stream { newStream ( 30 , identity , ` { app="bar"} ` ) } ) ,
} ,
{
` rate( { app="foo"} |~".+bar" [1m]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 120 , 0 ) , time . Minute , logproto . BACKWARD , 10 ,
` { app="barf"} |= "foo" |~ ".+bar" ` , time . Unix ( 0 , 0 ) , time . Unix ( 30 , 0 ) , 0 , 3 * time . Second , logproto . BACKWARD , 30 ,
[ ] [ ] * logproto . Stream {
{ newBackwardStream ( testSize , identity , ` { app="barf"} ` ) } ,
} ,
[ ] SelectParams {
{ & logproto . QueryRequest { Direction : logproto . BACKWARD , Start : time . Unix ( 0 , 0 ) , End : time . Unix ( 30 , 0 ) , Limit : 30 , Selector : ` { app="barf"}|="foo"|~".+bar" ` } } ,
} ,
Streams ( [ ] * logproto . Stream { newBackwardIntervalStream ( testSize , 30 , 3 * time . Second , identity , ` { app="barf"} ` ) } ) ,
} ,
{
` rate( { app="foo"} |~".+bar" [1m]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 120 , 0 ) , time . Minute , 0 , logproto . BACKWARD , 10 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , identity , ` { app="foo"} ` ) } ,
} ,
@ -388,7 +419,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` rate( { app="foo"}[30s]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 120 , 0 ) , 15 * time . Second , logproto . FORWARD , 10 ,
` rate( { app="foo"}[30s]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 120 , 0 ) , 15 * time . Second , 0 , logproto . FORWARD , 10 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 2 , identity ) , ` { app="foo"} ` ) } ,
} ,
@ -403,7 +434,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` count_over_time( { app="foo"} |~".+bar" [1m]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 120 , 0 ) , 30 * time . Second , logproto . BACKWARD , 10 ,
` count_over_time( { app="foo"} |~".+bar" [1m]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 120 , 0 ) , 30 * time . Second , 0 , logproto . BACKWARD , 10 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) } , // 10 , 20 , 30 .. 60 = 6 total
} ,
@ -418,7 +449,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` count_over_time(( { app="foo"} |~".+bar")[5m]) ` , time . Unix ( 5 * 60 , 0 ) , time . Unix ( 5 * 120 , 0 ) , 30 * time . Second , logproto . BACKWARD , 10 ,
` count_over_time(( { app="foo"} |~".+bar")[5m]) ` , time . Unix ( 5 * 60 , 0 ) , time . Unix ( 5 * 120 , 0 ) , 30 * time . Second , 0 , logproto . BACKWARD , 10 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) } , // 10 , 20 , 30 .. 300 = 30 total
} ,
@ -445,7 +476,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` avg(count_over_time( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` avg(count_over_time( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 10 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -460,7 +491,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` min(rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` min(rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 10 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -475,7 +506,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` max by (app) (rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` max by (app) (rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -494,7 +525,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` max(rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` max(rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -509,7 +540,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` sum(rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` sum(rate( { app=~"foo|bar"} |~".+bar" [1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -524,7 +555,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` sum(count_over_time( { app=~"foo|bar"} |~".+bar" [1m])) by (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` sum(count_over_time( { app=~"foo|bar"} |~".+bar" [1m])) by (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -543,7 +574,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` count(count_over_time( { app=~"foo|bar"} |~".+bar" [1m])) without (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` count(count_over_time( { app=~"foo|bar"} |~".+bar" [1m])) without (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 10 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -558,7 +589,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` stdvar without (app) (count_over_time(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` stdvar without (app) (count_over_time(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -573,7 +604,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` stddev(count_over_time(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` stddev(count_over_time(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 2 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -588,7 +619,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` rate(( { app=~"foo|bar"} |~".+bar")[1m]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` rate(( { app=~"foo|bar"} |~".+bar")[1m]) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -607,7 +638,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` topk(2,rate(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` topk(2,rate(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) , newStream ( testSize , factor ( 15 , identity ) , ` { app="boo"} ` ) } ,
} ,
@ -626,7 +657,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` topk(1,rate(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` topk(1,rate(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) } ,
} ,
@ -641,7 +672,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` topk(1,rate(( { app=~"foo|bar"} |~".+bar")[1m])) by (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` topk(1,rate(( { app=~"foo|bar"} |~".+bar")[1m])) by (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 15 , identity ) , ` { app="fuzz"} ` ) ,
newStream ( testSize , factor ( 5 , identity ) , ` { app="fuzz"} ` ) , newStream ( testSize , identity , ` { app="buzz"} ` ) } ,
@ -665,7 +696,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` bottomk(2,rate(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` bottomk(2,rate(( { app=~"foo|bar"} |~".+bar")[1m])) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{ newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) , newStream ( testSize , factor ( 20 , identity ) , ` { app="bar"} ` ) ,
newStream ( testSize , factor ( 5 , identity ) , ` { app="fuzz"} ` ) , newStream ( testSize , identity , ` { app="buzz"} ` ) } ,
@ -685,7 +716,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
} ,
{
` bottomk(3,rate(( { app=~"foo|bar|fuzz|buzz"} |~".+bar")[1m])) without (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
` bottomk(3,rate(( { app=~"foo|bar|fuzz|buzz"} |~".+bar")[1m])) without (app) ` , time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 10 , identity ) , ` { app="foo"} ` ) ,
@ -715,7 +746,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
// binops
{
` rate( { app="foo"}[1m]) or rate( { app="bar"}[1m]) ` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -744,7 +775,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
rate ( { app = ~ "foo|bar" } [ 1 m ] ) and
rate ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -770,7 +801,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
rate ( { app = ~ "foo|bar" } [ 1 m ] ) unless
rate ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -796,7 +827,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
rate ( { app = ~ "foo|bar" } [ 1 m ] ) +
rate ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -822,7 +853,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
rate ( { app = ~ "foo|bar" } [ 1 m ] ) -
rate ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -848,7 +879,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
count_over_time ( { app = ~ "foo|bar" } [ 1 m ] ) *
count_over_time ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -874,7 +905,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
count_over_time ( { app = ~ "foo|bar" } [ 1 m ] ) *
count_over_time ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -900,7 +931,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
count_over_time ( { app = ~ "foo|bar" } [ 1 m ] ) /
count_over_time ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -926,7 +957,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
count_over_time ( { app = ~ "foo|bar" } [ 1 m ] ) %
count_over_time ( { app = "bar" } [ 1 m ] )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -954,7 +985,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
sum by ( app ) ( rate ( { app = ~ "foo|bar" } | ~ ".+bar" [ 1 m ] ) ) /
sum by ( app ) ( rate ( { app = ~ "foo|bar" } | ~ ".+bar" [ 1 m ] ) )
` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="foo"} ` ) ,
@ -977,7 +1008,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
{
` 1+1--1 ` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream { } ,
[ ] SelectParams { } ,
promql . Matrix {
@ -988,7 +1019,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
{
` rate( { app="bar"}[1m]) - 1 ` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) ,
@ -1006,7 +1037,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
{
` 1 - rate( { app="bar"}[1m]) ` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) ,
@ -1024,7 +1055,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
{
` rate( { app="bar"}[1m]) - 1 / 2 ` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) ,
@ -1042,7 +1073,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
{
` count_over_time( { app="bar"}[1m]) ^ count_over_time( { app="bar"}[1m]) ` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream {
{
newStream ( testSize , factor ( 5 , identity ) , ` { app="bar"} ` ) ,
@ -1060,7 +1091,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
} ,
{
` 2 ` ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , logproto . FORWARD , 100 ,
time . Unix ( 60 , 0 ) , time . Unix ( 180 , 0 ) , 30 * time . Second , 0 , logproto . FORWARD , 100 ,
[ ] [ ] * logproto . Stream { } ,
[ ] SelectParams { } ,
promql . Matrix {
@ -1076,7 +1107,7 @@ func TestEngine_NewRangeQuery(t *testing.T) {
eng := NewEngine ( EngineOpts { } , newQuerierRecorder ( test . streams , test . params ) )
q := eng . NewRangeQuery ( test . qs , test . start , test . end , test . step , test . direction , test . limit )
q := eng . NewRangeQuery ( test . qs , test . start , test . end , test . step , test . interval , test . direction , test . limit )
res , err := q . Exec ( context . Background ( ) )
if err != nil {
t . Fatal ( err )
@ -1148,7 +1179,7 @@ func benchmarkRangeQuery(testsize int64, b *testing.B) {
{ ` bottomk(2,rate(( { app=~"foo|bar"} |~".+bar")[1m])) ` , logproto . FORWARD } ,
{ ` bottomk(3,rate(( { app=~"foo|bar"} |~".+bar")[1m])) without (app) ` , logproto . FORWARD } ,
} {
q := eng . NewRangeQuery ( test . qs , start , end , 60 * time . Second , test . direction , 1000 )
q := eng . NewRangeQuery ( test . qs , start , end , 60 * time . Second , 0 , test . direction , 1000 )
res , err := q . Exec ( context . Background ( ) )
if err != nil {
b . Fatal ( err )
@ -1230,6 +1261,47 @@ func newStream(n int64, f generator, labels string) *logproto.Stream {
}
}
func newIntervalStream ( n int64 , step time . Duration , f generator , labels string ) * logproto . Stream {
entries := [ ] logproto . Entry { }
lastEntry := int64 ( - 100 ) // Start with a really small value (negative) so we always output the first item
for i := int64 ( 0 ) ; int64 ( len ( entries ) ) < n ; i ++ {
if float64 ( lastEntry ) + step . Seconds ( ) <= float64 ( i ) {
entries = append ( entries , f ( i ) )
lastEntry = i
}
}
return & logproto . Stream {
Entries : entries ,
Labels : labels ,
}
}
func newBackwardStream ( n int64 , f generator , labels string ) * logproto . Stream {
entries := [ ] logproto . Entry { }
for i := n - 1 ; i > 0 ; i -- {
entries = append ( entries , f ( i ) )
}
return & logproto . Stream {
Entries : entries ,
Labels : labels ,
}
}
func newBackwardIntervalStream ( n , expectedResults int64 , step time . Duration , f generator , labels string ) * logproto . Stream {
entries := [ ] logproto . Entry { }
lastEntry := int64 ( 100000 ) //Start with some really big value so that we always output the first item
for i := n - 1 ; int64 ( len ( entries ) ) < expectedResults ; i -- {
if float64 ( lastEntry ) - step . Seconds ( ) >= float64 ( i ) {
entries = append ( entries , f ( i ) )
lastEntry = i
}
}
return & logproto . Stream {
Entries : entries ,
Labels : labels ,
}
}
func identity ( i int64 ) logproto . Entry {
return logproto . Entry {
Timestamp : time . Unix ( i , 0 ) ,