Optimal approach to group data by field

Hi all

I’m very new to the time series topic and I would like to understand if I can achieve my requirement with a specific query.

Currently the data in the my bucket looks like this

What I would like to understand is, how long it takes until a ticket_number changes. My idea was to group the data by the ticket_number and get the max from the _time field and do the rest with my programming language of choice.
Is there are more time series way to do this? I would like to report the average time to the user for the last e.g. 15mins

Thanks for all the help and pointers :slight_smile: