Skip to content

feat: avoid historical Loki live-tail queries#397

Merged
pawelkuc merged 1 commit intomainfrom
fix-tail-query
May 5, 2026
Merged

feat: avoid historical Loki live-tail queries#397
pawelkuc merged 1 commit intomainfrom
fix-tail-query

Conversation

@pawelkuc
Copy link
Copy Markdown
Contributor

@pawelkuc pawelkuc commented May 4, 2026

Follow mode previously passed the normal log start time into Loki's websocket tail endpoint. With the default 30 day window, apps with a lot of logs could force Loki to establish a live tail over a big historical range, putting pressure on queriers and query frontends.

We now fetch the requested backlog with the range query API first, then start the websocket tail from the end of that range.

Copy link
Copy Markdown
Contributor

@thirdeyenick thirdeyenick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. So the QueryRange call query is more performant than the TailQuery call with longer periods of data, right?

@pawelkuc
Copy link
Copy Markdown
Contributor Author

pawelkuc commented May 4, 2026

Yes, exactly. TailQuery seems to be optimized for the live streaming part. I also tested this locally against the debug scenario, and the fix worked without issues there.

Follow mode previously passed the normal log start time into Loki's websocket
tail endpoint. With the default 30 day window, apps with a lot of logs could
force Loki to establish a live tail over a big historical range, putting
pressure on queriers and query frontends.

We now fetch the requested backlog with the range query API first, then start
the websocket tail from the end of that range.
@pawelkuc pawelkuc merged commit 2b149cc into main May 5, 2026
3 checks passed
@pawelkuc pawelkuc deleted the fix-tail-query branch May 5, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants