title: Grafana, ElasticSearch - Graph of calculated elapsed time between two flow tasks
body: <p>I'm new to Grafana and ElasticSearch.
  We have data in ES with log records of a processing flow with multiple microservices. There are several types of those microservices.
  For simplicity, let's assume that there are two type of microservices 'task1' and 'task2' and each processing flow has a unique traceId value.
  The data is something like the following:</p>
  <pre><code>{traceId: 'job1', service: 'task1', eventTime: '2021-02-19 12:01:00'}
  {traceId: 'job2', service: 'task1', eventTime: '2021-02-19 12:02:00'}
  {traceId: 'job1', service: 'task2', eventTime: '2021-02-19 12:05:00'}
  {traceId: 'job2', service: 'task2', eventTime: '2021-02-19 12:10:00'}
  
  </code></pre>
  <p>I would like to add a grafana panel to our dashboard that will have the elapsed time (the time difference between 'task1' and 'task2') for each processing flow ('job1', 'job2'...).
  I search for similar issue and found the discussion in <a href="https://stackoverflow.com/questions/21902423/how-to-create-query-which-can-calculate-time-difference">how to create query which can calculate time difference?</a>, but I'm not sure if the solution described there is suitable for my problem and I couldn't find a way to add the aggregate filter described there. I guess it is way above my current knowledge.
  Any help would be appreciate</p>