Query last log by labels

My web app creates log files per http request. How can I create a query that shows the latest log files ? I tried the following which gives me the filenames but seems to disregard the order:

count by (filename) (count_over_time({host="$host",customer=~"${customer:regex}"} [$__range]))

It’s like i need to query to get the last log entries grouped by host/customer/filename.