# Calculating Windows User Session Duration

**URL:** <https://discuss.elastic.co/t/calculating-windows-user-session-duration/351362>\
**Category:** Kibana\
**Created:** [January 18, 2024, 3:05pm UTC](https://discuss.elastic.co/t/calculating-windows-user-session-duration/351362 "2024-01-18T15:05:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcharles1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pcharles1/32/94519_2.png) [@pcharles1](https://discuss.elastic.co/u/pcharles1)\
**Post date:** [January 18, 2024, 3:05pm UTC](https://discuss.elastic.co/t/calculating-windows-user-session-duration/351362/1 "2024-01-18T15:05:28Z")

</div>

I need to calculate Windows user session duration times using winlogbeat event codes like 4624 (login) and 4634 (logout) & create a visualization to display each user's duration. I'm using a heatmap visualization. I found an old thread with a similar objective here:

> [@User session duration calculation](https://discuss.elastic.co/t/user-session-duration-calculation/290993):
>
> Hi, I'm trying to get user session duration by day for the last 30 days from windows logs, so I used Transform but something wrong in my script, I always get duration for all period recorded: from the first login to the last logout. I saw all similar subjet, but I didn't find somthing working for me. PUT \_transform/windows-login-durations { "source": { "index": ["windows-security-logs-\*"], "query": { "bool": { "should": [ { "bool": { …

I created a continuous transform using an identical aggregation however the destination index contains gaps ie several months with no data when the source indices are populated for the last 90-100 days.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/1/41c8920ff26f15fa10af7b95c7b457761be1903f.png)

For added context, I initially created a batch transform that did populate the data for the entire time period. The issue was that it doesn't continue updating since batch transforms only run once. This is why I switched to continuous.

Does anyone know why there's gaps in the data? I need the transform to run over the entire source index chronologically and continue updating the destination index on a daily basis.

P.S. If there's a more efficient way of tackling this problem, I'm open to suggestions. Thanks!

---

<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 15, 2024, 3:06pm UTC](https://discuss.elastic.co/t/calculating-windows-user-session-duration/351362/2 "2024-02-15T15:06:01Z")

</div>

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