Splunk Search

How to edit my search that retrieves the start and end time of user from Active Directory logs?

kiran331
Builder

Hi

How to get the start time and end time of the user from AD logs,

The result which I need is

user   "logon time"   "logofftime"  duration date
....

....

The search I tried but, it's not working as expected

index=wineventlog sourcetype="WinEventLog:Security" | eval time=_time     | stats values(min(time)) as "Logon Time", values(max(time)) as "Logoff Time" by user   | convert  timeformat="%m/%d/%y %H:%M:%S" ctime(*) 
0 Karma

neelamsantosh
Path Finder

If u r spanning Per day wise use min(_time) for first time ad authentication and max(_time) for recent/last time authenticated time.

0 Karma

hunters_splunk
Splunk Employee
Splunk Employee

Hi Kiran,

I think you should use the earliest and latest commands instead of min and max.
Please try this search:

index=wineventlog sourcetype="WinEventLog:Security" | stats earliest(_time) as logon, latest(_time) as logoff by clientip | eval duration=tostring(logoff-logon,"duration") | eval logon = strftime(logon,"%D %T") | eval logoff = strftime(logoff,"%D %T")

Hope this helps. Thanks!
Hunter

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...