How to paginate Loki queries

How to paginate Loki queries

I could be wrong, but I don’t think there is a built-in way to do this.

Loki’s LogCLI tool has a --limit and --batch options you can use that’ll return paginate results for you, see LogCLI | Grafana Loki documentation.

If you don’t want to use LogCLI, you can see in the code how they do it. Essentially a query is performed with the limit, then the timestamp of the last log is used as the starting timestamp for the next query, and then there is some de-dup done at the end. See loki/pkg/logcli/query/query.go at main · grafana/loki · GitHub