Get a series of logs with offset using API /query_range

Hello,
I’m new to Loki and LogQL queries. What I’m trying to do is simply to get a JSON of log lines based on a GET request from our backend in the form “GET /logs?cpid=…&limit=10&offset=100” where limit is a numder of loglines and offset is a shift counter between the last log line and the start of required series using HTTP Loki API.

/loki/api/v1/query_range returns the stream I need with query parameters

'{query': '{ cpeid="DMS_DEVICE"}| json |line_format "{{.log}}" ','limit': '10'}

only for the most recent log lines. I heard of the PromQL offset feature, but it seems like it is absend in LogQL. And I don’t know the exact timestamp of the starting log line.

So my question is how can I implement the offset based not on times but by counting individual log lines?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.