Why loki download logs in a reverse order only?

When downloading logs of a certain pod, the newest logs are on the top which is confusing for any user, is there any way to download in the normal order (Ascendant order)?

1 Like

Yes there is.

If you’re using Grafana:

Note the “direction” setting at the bottom of the screenshot, and the query API are also takes a direction parameters.

Which version of grafana is this because mine only shows a ‘Flip results order’ button and when i click it i get the same results:

Yeah that’s the same feature, just renamed I believe.

It shouldn’t be returning the same results, though.

Please select

and then in the Query tab


execute the query and send me the request URL.

I clicked on Flip results order and then run the query, here is the request url in the inspector the direction is always BACKWORD


Unfortunately I think Grafana only reverses the order of the logs returned and doesn’t issue a “forward” query.

You can use logcli to issue a --forward query.

I think it would be nice if the button in Grafana did this rather than just reversing the results

Would you consider opening an issue in the Grafana repo?

Ok, but is there any workaround other than using LogCli to make logs direction always forward?

@dannykopping in which grafana and loki version I can find that ‘Display results’ option?

I’m running v8.5.0, which version are you on?

I run v8.4.3, which is the latest release

Ah, I appear to be running the pre-release version.
If the UI is not changing the direction parameter, that is a bug and should be reported at GitHub - grafana/grafana: The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more. please.

1 Like

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