Splunk Search

How do I calculate the duration between Login and Logout of user?

jtabilas
Loves-to-Learn Everything

Hi guys! I want see the avg duration of activity of user on Splunk, but i didn't find the field of logout. 1.png

 
Labels (1)
0 Karma

dural_yyz
Motivator

To find login and logout sessions here is the search you want.

index=_audit sourcetype=audittrail action IN ("login attempt" logout)

For some reason the field extractions for action only work on my DMC and not my search heads so be cautious and edit the search where needed.  This tracks by user which is really easy.

 

However since most users will not actually log out and rather the behavior is to close the browser window the session will timeout.  You can map the log in session which is a field in the above login action.  The session timeout does not map a username value though.

index=_audit sourcetype=audittrail action=expired_session_token info=expired

There will be one log for each search head in your cluster.  So if you have a 5 search head cluster you will see a single login action but then 5 session timeout values. 

gcusello
SplunkTrust
SplunkTrust

Hi @jtabilas ,

for my knowldege, Splunk records only the login and log fail events.

Ciao.

Giuseppe

0 Karma

jtabilas
Loves-to-Learn Everything

Can i monitor the session of user?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jtabilas ,

you could see the _audit logs and consider closed a session when there's an inactivity perior greater than e.g. 5 minutes or the session timeout you configured.

then you can consider the last event in _audit as logout.

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...