Splunk Search

lookup value based on current search results

lbrhyne
Path Finder

New to Splunk and having a difficult time returning the correct results. The below query works... meaning that it converts the email address to user from the identities index and successfully looks up the value of user in the wineventlog index that contain either EventCode 4624 or 4625 based on the provide critera. However, when the stats are listed in the table after the query has completed, the values(user) as "Login ID" does not line up with values(fullname) as "Full Name", values(department) as Department and the device name does not show. Example: Login ID = tJones Full Name = Sammy Smith The goal is to have all the fields line up simular to Tjone | Tom Jones | Department Name | Device. Thanks in advance for any assistance provided.

index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d
| eval user = trim(replace(email, "@domain.com", ""))
| search  [ | search index="wineventlog"  sourcetype="WinEventLog:Security" (EventCode=4624 AND Logon_Type=2) OR EventCode=4625 earliest=-10m latest=now()| fields user| format]
| table user,department,ad_fname,ad_last_name, Workstation_Name
| eval fullname = toString(ad_fname) + " " + toString(ad_last_name)
| stats values(user) as "Login ID", values(fullname) as "Full Name", values(department) as Department, values(Workstation_Name) as Device
Tags (1)
0 Karma
1 Solution

jawaharas
Motivator

To rename a field use 'rename' command not 'stats' which is to categorize data based on a particular field.

index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d 
| eval user = trim(replace(email, "@domain.com", "")) 
| search 
    [| search index="wineventlog" sourcetype="WinEventLog:Security" (EventCode=4624 AND Logon_Type=2) OR EventCode=4625 earliest=-10m latest=now() 
    | table user ] 
| eval fullname = toString(ad_fname) + " " + toString(ad_last_name) 
| table user,department,ad_fname,ad_last_name, Workstation_Name
| rename user as "Login ID", fullname as "Full Name", department as Department, Workstation_Name as Device

Reference:
https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Stats
https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Rename

View solution in original post

0 Karma

jawaharas
Motivator

To rename a field use 'rename' command not 'stats' which is to categorize data based on a particular field.

index=identities sourcetype="Vantage" ee_status=* earliest=-1d@d latest=-0d@d 
| eval user = trim(replace(email, "@domain.com", "")) 
| search 
    [| search index="wineventlog" sourcetype="WinEventLog:Security" (EventCode=4624 AND Logon_Type=2) OR EventCode=4625 earliest=-10m latest=now() 
    | table user ] 
| eval fullname = toString(ad_fname) + " " + toString(ad_last_name) 
| table user,department,ad_fname,ad_last_name, Workstation_Name
| rename user as "Login ID", fullname as "Full Name", department as Department, Workstation_Name as Device

Reference:
https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Stats
https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Rename

0 Karma

lbrhyne
Path Finder

Thank you Jawaharas, that worked! The last thing I'm still not able to pull into the report is the Device name from the wineventlog, as it remains to be blank.

0 Karma

woodcock
Esteemed Legend

You should click Accept to close this question and if you have something different (even if related), ask another.

0 Karma

jawaharas
Motivator

Kindly accept the answer it it helped you, so others can refer it.

The field names are case sensitive. Verify the field name 'Workstation_Name'

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...