diff --git a/pkg/pattern/aggregation/push.go b/pkg/pattern/aggregation/push.go index 7b7a7777ab28b..d5f755b07ddbb 100644 --- a/pkg/pattern/aggregation/push.go +++ b/pkg/pattern/aggregation/push.go @@ -177,6 +177,9 @@ func (p *Push) buildPayload(ctx context.Context) ([]byte, error) { defer sp.Finish() entries := p.entries.reset() + if len(entries) == 0 { + return nil, nil + } entriesByStream := make(map[string][]logproto.Entry) for _, e := range entries { @@ -219,6 +222,10 @@ func (p *Push) buildPayload(ctx context.Context) ([]byte, error) { } } + if len(streams) == 0 { + return nil, nil + } + req := &logproto.PushRequest{ Streams: streams, } @@ -268,6 +275,10 @@ func (p *Push) run(pushPeriod time.Duration) { continue } + if len(payload) == 0 { + continue + } + // We will use a timeout within each attempt to send backoff := backoff.New(context.Background(), *p.backoff)