# How to calculate elapsedtime using logstash

**URL:** <https://discuss.elastic.co/t/how-to-calculate-elapsedtime-using-logstash/114481>\
**Category:** Logstash\
**Created:** [January 8, 2018, 9:31am UTC](https://discuss.elastic.co/t/how-to-calculate-elapsedtime-using-logstash/114481 "2018-01-08T09:31:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![klymptzic](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@klymptzic](https://discuss.elastic.co/u/klymptzic)\
**Post date:** [January 8, 2018, 9:31am UTC](https://discuss.elastic.co/t/how-to-calculate-elapsedtime-using-logstash/114481/1 "2018-01-08T09:31:29Z")

</div>

Hi Everyone,

I need to extract response time of an event by calculating elapsedtime from start and end time

excerpts from log:  
08-12-17 04:38:17:090 [INFO] [thread-1] [User1] c.s.s.i.a.t.JavaClass1 - Loading Data from  
08-12-17 04:49:38:902 [INFO] [thread-10] [User1] c.s.s.i.a.t.JavaClass2 - Data loaded: #12

I need calc the elapsed time between 08-12-17 04:38:17 & 08-12-17 04:49:38:902. The difference is the time taken to load data that I need to plot/visualize in Kibana.

Need to plot this for multiple users who had performed the event  
User1 - 0:11:21  
User2 - 0:10:01  
for instance..

Appreciate your help.

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [January 8, 2018, 12:09pm UTC](https://discuss.elastic.co/t/how-to-calculate-elapsedtime-using-logstash/114481/2 "2018-01-08T12:09:54Z")

</div>

Can you do this as a calculated value in Kibana?

If not try the elapsed filter [https://www.elastic.co/guide/en/logstash/6.0/plugins-filters-elapsed.html](https://www.elastic.co/guide/en/logstash/6.0/plugins-filters-elapsed.html)

With this filter though, you should understand that it needs to "see" all events **in original order**. Due to the fact that LS runs in a multi-threaded way there is no guarantee that a thread that takes a batch with a "start" event will have stored the start event in the elapsed filter before the second thread processes the "stop" event. Say Batch 1 has 125 events and the start event is number 121 and in Batch 2 the stop event is number 5 - it follows that thread 1 (with batch 1) needs to process 120 events before it gets to the start event whereas thread 2 (with batch 2) only needs to process 4 events before it reaches the stop event.  
Therefore you need to set `pipeline.workers: 1` in your logstash.yml. This is why I suggested the Kibana method if you can get it to work.

---

<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:** [February 5, 2018, 12:10pm UTC](https://discuss.elastic.co/t/how-to-calculate-elapsedtime-using-logstash/114481/3 "2018-02-05T12:10:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
