How to plot time between 2 events?

Hi guys, I have some devices which report events to my server and I think about improving that event monitoring with a nice grafana dashboard. After some playing around and searching google I am just pretty unsure if my data is in the right format for that/my plans are even possible with influxdb and grafana?

2 Example events:

duration_test,device=d1,event_id=5432,action=recording_start value=1
duration_test,device=d1,event_id=5432,action=recording_end value=1
duration_test,device=d2,event_id=5433,action=recording_start value=1
duration_test,device=d2,event_id=5433,action=recording_end value=1

The result I am looking for:

  • A graph that plots the avg duration between all recording_start/end actions from all devices.

A possible solution is to calculate the duration on the devices and send it with the recording_end event of course but if possible I would like to do it without. Since I have a lot of ideas for other dashboards where I would need the option to calculate the time between 2 points inside a influxdb query. (For example show the count of devices where the recording_start event got sent more than 2h ago and the recording_end was not sent yet)

Thanks for reading through my plans, if you have any ideas/suggestions I would love to hear them!

Hi
Did you get a solution to this question I have much the same challenge in an event driven system
Thanks