# Query for correlating records

**URL:** <https://discuss.elastic.co/t/query-for-correlating-records/42307>\
**Category:** Elasticsearch\
**Created:** [February 20, 2016, 3:21pm UTC](https://discuss.elastic.co/t/query-for-correlating-records/42307 "2016-02-20T15:21:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jan.ostgren](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@jan.ostgren](https://discuss.elastic.co/u/jan.ostgren)\
**Post date:** [February 20, 2016, 3:21pm UTC](https://discuss.elastic.co/t/query-for-correlating-records/42307/1 "2016-02-20T15:21:34Z")

</div>

Hi,  
I have log file with transactions that have log records for start and stop of transactions.  
It looks like this simplified.  
:::\<start|stop\>::

I want to a measure the time between start and stop as the response time for a transaction with same id,

How do I do it in Elasticsearch and how do I visualize graph in Kibana ?.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 21, 2016, 3:20pm UTC](https://discuss.elastic.co/t/query-for-correlating-records/42307/2 "2016-02-21T15:20:00Z")

</div>

If the start/stop records occur close enough together there's a Logstash feature that holds a window of the last N records and can be used to join stops with starts and calculate the duration. Try asking in the Logstash forum here.  
If the transactions are longer running or you need robust delivery you might want to check out using entity centric indexing techniques : [https://m.youtube.com/watch?v=yBf7oeJKH2Y](https://m.youtube.com/watch?v=yBf7oeJKH2Y)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:14pm UTC](https://discuss.elastic.co/t/query-for-correlating-records/42307/3 "2017-07-05T23:14:37Z")

</div>


