Skip to content

Commit

Permalink
fix: don't send empty aggregated metric payloads (backport k236) (#15811
Browse files Browse the repository at this point in the history
)

Co-authored-by: Trevor Whitney <[email protected]>
  • Loading branch information
loki-gh-app[bot] and trevorwhitney authored Jan 16, 2025
1 parent 8e260fe commit 0a26743
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/pattern/aggregation/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0a26743

Please sign in to comment.