# Kibana, Is there a way to create session duration

**URL:** <https://discuss.elastic.co/t/kibana-is-there-a-way-to-create-session-duration/228745>\
**Category:** Kibana\
**Created:** [April 19, 2020, 4:37pm UTC](https://discuss.elastic.co/t/kibana-is-there-a-way-to-create-session-duration/228745 "2020-04-19T16:37:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![levi\_munthe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/levi_munthe/32/42202_2.png) [@levi\_munthe](https://discuss.elastic.co/u/levi_munthe)\
**Post date:** [April 19, 2020, 4:37pm UTC](https://discuss.elastic.co/t/kibana-is-there-a-way-to-create-session-duration/228745/1 "2020-04-19T16:37:58Z")

</div>

Hai guys, i am new in ELK and have an issue to create a session duration between 2 field. Here is the data below.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/3/b38f22fbbad2c230cf6416882e73f8d6d15d6cf8.png)

the yellow mark is the data that i want to calculate the time. my logic is to grouping the data with session and calculate the time by (recent time - oldest time) or (top 1 CreateAt\_descending - top 1 CreateAt\_ascending) to calculate the session duration. is there any way to get this result.

Thanks.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [April 19, 2020, 7:33pm UTC](https://discuss.elastic.co/t/kibana-is-there-a-way-to-create-session-duration/228745/2 "2020-04-19T19:33:44Z")

</div>

You can create a custom field for calculating the time difference using the painless script. There is an example available at [https://www.elastic.co/blog/using-painless-kibana-scripted-fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields) Hope it helps

Thanks  
Rashmi

---

<div class="post-metadata">

**Author:** ![levi\_munthe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/levi_munthe/32/42202_2.png) [@levi\_munthe](https://discuss.elastic.co/u/levi_munthe)\
**Post date:** [April 20, 2020, 3:12pm UTC](https://discuss.elastic.co/t/kibana-is-there-a-way-to-create-session-duration/228745/3 "2020-04-20T15:12:55Z")

</div>

Thanks for answering. i will try to understand this language haha.  
Because am not so familiar with this language, it's so different from SQL.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [April 20, 2020, 3:40pm UTC](https://discuss.elastic.co/t/kibana-is-there-a-way-to-create-session-duration/228745/4 "2020-04-20T15:40:05Z")

</div>

Yes, There is a learning curve. Here is a brief walkthrough which might help: [https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-walkthrough.html](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-walkthrough.html)

---

<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:** [May 18, 2020, 3:40pm UTC](https://discuss.elastic.co/t/kibana-is-there-a-way-to-create-session-duration/228745/5 "2020-05-18T15:40:05Z")

</div>

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