# Calculation of time spent in the system

**URL:** <https://discuss.elastic.co/t/calculation-of-time-spent-in-the-system/45214>\
**Category:** Kibana\
**Created:** [March 23, 2016, 11:59am UTC](https://discuss.elastic.co/t/calculation-of-time-spent-in-the-system/45214 "2016-03-23T11:59:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prateek\_Kshtriya](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@Prateek\_Kshtriya](https://discuss.elastic.co/u/Prateek_Kshtriya)\
**Post date:** [March 23, 2016, 11:59am UTC](https://discuss.elastic.co/t/calculation-of-time-spent-in-the-system/45214/1 "2016-03-23T11:59:27Z")

</div>

Hi All,

I have a data for visualization which is like some states are generated for a specific ID at different time stamp.  
Now I am able to create a table with all details. Please let me know if it is possible to get the difference of time so I could plot a vertical bar chart or line chart corresponding to different ID's giving details of time spent in the system.

PFB sample data in data table having different states, state ID & time stamp for selected ID : -  
ConversationID: Ascending Conversation\_StateID: Ascending Conversation\_Status\_Desc: Ascending @timestamp per minute Count  
00a53828f5444aa8aea0980c7327509 0c2fd12172934849a7387545605a3b2a processing February 25th 2016, 12:50:00.000 1  
00a53828f5444aa8aea0980c7327509 54e1ce468c644cb88ec99daa358c9c31 readyforprocessing February 25th 2016, 12:50:00.000 1  
00a53828f5444aa8aea0980c7327509 5f02e489e38148d0b1ea72f12a94c3cc new February 25th 2016, 12:50:00.000 1  
00a53828f5444aa8aea0980c7327509 e252080a9ae64e3f8535a40e5a8a8290 readyforsubscription February 25th 2016, 12:46:00.000 1

Regards,  
Prateek

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [March 24, 2016, 8:08pm UTC](https://discuss.elastic.co/t/calculation-of-time-spent-in-the-system/45214/2 "2016-03-24T20:08:35Z")

</div>

Hi Prateek,

Kibana doesn't have anything built-in that would take the difference between documents related by an ID, but it has some scripting functionality.

Here's a link to another post where a script is used to build a metric about concurrent events. It might provide some ideas;

> [@Display concurrency in data on Kibana](https://discuss.elastic.co/t/display-concurrency-in-data-on-kibana/26006/13):
>
> It worked for me with the following data and config: curl -XPOST 'http://localhost:9200/test3' -d '{ "settings" : { "number\_of\_shards" : 1 }, "mappings" : { "test" : { "properties" : { "start\_date" : { "type" : "date"}, "end\_date" : { "type" : "date"}, "duration" : { "type" : "integer"} } } } }' curl -XPUT 'http://localhost:9200/test3/test/1' -d '{ "start\_date" : "2015-08-23T00:0…

Another option might be the Timelion plugin to Kibana. Here's one video about it but if you search you'll find more; [https://www.elastic.co/videos/time-series-analysis-using-timelion](https://www.elastic.co/videos/time-series-analysis-using-timelion)

But this is a fairly common question. I'll try to come up with a good solution and post it back here.

Regards,  
Lee

---

<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 6, 2017, 1:57pm UTC](https://discuss.elastic.co/t/calculation-of-time-spent-in-the-system/45214/3 "2017-07-06T13:57:54Z")

</div>


