Find time difference between series of events with uniqueid

You may be able to use an aggregate filter. See example 3 in the documentation.

An example of calculating time difference is here.