How to get last X documents sorted by a timestamp

filter by type of event. sort on the time stamp and set size to 1?

But I might be missing the problem.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.