Getting Data In

Finding the 1st logon and logoff event times for a single user from March 2017 to present.

JPurdham
Engager

Hello,

I've been asked to find the 1st login time of a user and the time they logged out over a specific date range. (march 1st 2017 - present)

The environment is a Window's terminal services environment (Windows Server 2008 R2) and is being indexed into Splunk. The index is index= index="wineventlog"

I'd like to see something like this; (if possible)

  • username: user
  • date: 01/MAR/2017
  • Logon: 07:30:00
  • Logoff: 15:30:00

For each day from march 1st to present, I can find the events but can't order them or filter them to show just the 1st login and last logoff of that day.

Appreciate the help,
Jake

gcusello
SplunkTrust
SplunkTrust

Hi JPurdham,
it's not a problem to have the first logon (EventCode=4624) but the problem is that in Windows a logon action generates many (more than 10) logon events (4624, 4672, 4634, ...) and it's difficoult to find the real logoff because there isn't a transaction code to connect events.
You could use username, but if you have more logons of the same user on the same host in the same day you cannot distinguish them.
Anyway, you could run something like this in the time period you need:

index=wineventlog sourcetype=WinEventLog:Security (EventCode=4624 OR EventCode=4634)
| eval day=strftime(_time,"%d/%m/%Y")
| stats earliest(_time) AS earliest latest(_time) AS latest by user host day
| eval earliest=strftime(earliest,"%d/%m/%Y %H.%M.%S"), latest=strftime(latest,"%d/%m/%Y %H.%M.%S")

Bye.
Giuseppe

benbabich
Explorer

This worked great for me.
After I Americanized the date format.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi JPurdham,
if this answer solves your problem, please accept and/or upvote it for the other people of the Community.
Ciao and next time.
Giuseppe

0 Karma

nick405060
Motivator

Is this still true? I've been asked to do pretty much the exact same thing. Not logon and logoff times each day, but time spent on a specific server/resource

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...