Query to calculate the time difference between two metrics (wait time) using prometheus

Hi,

I am looking for a query to calculate the wait time between two metrics.

Details:

metric1 (component=“xyz”, activityEndTime=“epoch time1”) — created at 10/31/2021 09:47:00 AM
metric1 (component=“abc”, activityEndTime=“epoch time2”) — created at 10/31/2021 09:52:00 AM

Looking for the query either time difference between the metrics (metric1 - metric1) or retrieving activityEndTime and calculate the difference in time (epoch time2 - epoch time1 = 5 mins).

Any help is greatly appreciated.

Thanks,
Vijay