Maximise returns on a LogQL query

The reason topk returns more results is because of the nature of how it works: topk is evaluated at each step, this means you can end up with more than 5 results as the top 5 results you are looking for are being evaluated at every step and may be different. I recommend to check out this detailed explanation on why is it happening and how you can resolve it:

You can also check out Loki dashboard on play site Grafana. Under Acquisition and Behaviour row we have couple of topk queries that you check out as well!