Getting Data In

How do you search, by day, for the first and the last user to log in and log off in a Windows event?

yassy
Explorer

Good morning, I'm doing a search to bring users and their first log in of the day and their last log off.
I made the following query, but I can not get the first line of the 4624 and the last one of the 4636 in the same line.

alt text

0 Karma

renjith_nair
Legend

@yassy ,

Give this a try

    index="your index" day="your day field"
    |stats earliest(eval(if(EventCode="4624",_time,null()))) as PrimerLogin,
              last(eval(if(EventCode="4634 ",_time,null()))) as UltimoLogoff by User,day
---
What goes around comes around. If it helps, hit it with Karma 🙂

yassy
Explorer

Tks finally i resolve it with this search

index=wineventlog (EventCode="4624" ) Account_Name!=AdminSp Account_Name!=AdminCitrix
| regex Account_Name!=".*\$"
| eval Day=strftime(_time,"%d/%m/%Y")
| eval User=mvindex(Account_Name,1)
| eval Time=strftime(_time,"%d/%m/%Y %H.%M.%S")
| stats earliest(Time) as PrimerLogin by User,Day

| join User,Day
[search
index=wineventlog (EventCode="4634" ) Account_Name!=AdminSp Account_Name!=AdminCitrix
| regex Account_Name!=".*\$"
| eval Day=strftime(_time,"%d/%m/%Y")
| eval User=Account_Name
| eval Time=strftime(_time,"%d/%m/%Y %H.%M.%S")
| stats latest(Time) as UltimoLogoff by User,Day
]
| stats values(PrimerLogin) as PrimerLogin,values(UltimoLogoff) as UltimoLogoff by User,Day

0 Karma

renjith_nair
Legend

@yassy , avoid join if possible. Wasn't the earlier search provided working?

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

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 ...