Splunk Search

How to match append result?

graceojo34
Loves-to-Learn

index=os process=sshd name="session opened" action=success
| eval user=upper(user)
| lookup all_svc_samaccountname.csv SamAccountName as user OUTPUT Match
| search Match =1
| eval dest=upper(dest)
| fields dest user
| lookup cmdb_all_assets.csv name as dest Output sys_class_name
| search sys_class_name=cmdb_ci*server
| eval User=mvindex(user,-1)
| eval AccountUsed=upper(User)
| search AccountUsed IN (*)
| fillnull value="Not Provided" AccountUsed
| lookup user_info_all.csv Samaccountname as AccountUsed OUTPUT department Samaccountname Owner_Samaccountname
| stats values(department) as Department latest(_time) as Time count by Owner_Samaccountname AccountUsed dest
| convert ctime(Time)
| rename dest as Target_Computer
| append [search index=wineventlog EventID IN (4648) ProcessName="C:\\Windows\\System32\\lsass.exe" source="XmlWinEventLog:Security" action=success |stats count by user ComputerName]
| table Time Owner_Samaccountname AccountUsed Department Target_Computer user ComputerName
| sort - Time

 

I I have these search query that returned the append fields values at the bottom to the the main search. My question is how can I match the fields?

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The trick is to use the stats command to regroup the results by a common field.  In this case, however, there is no common field.  If the 'user' field is the same as either 'Owner_Samaccountname' or 'AccountUsed' then you can use rename to create a common field.

index=os process=sshd name="session opened" action=success
| eval user=upper(user)
| lookup all_svc_samaccountname.csv SamAccountName as user OUTPUT Match
| search Match =1
| eval dest=upper(dest)
| fields dest user
| lookup cmdb_all_assets.csv name as dest Output sys_class_name
| search sys_class_name=cmdb_ci*server
| eval User=mvindex(user,-1)
| eval AccountUsed=upper(User)
| search AccountUsed IN (*)
| fillnull value="Not Provided" AccountUsed
| lookup user_info_all.csv Samaccountname as AccountUsed OUTPUT department Samaccountname Owner_Samaccountname
| stats values(department) as Department latest(_time) as Time count by Owner_Samaccountname AccountUsed dest
| convert ctime(Time)
| rename dest as Target_Computer
| append [search index=wineventlog EventID IN (4648) ProcessName="C:\\Windows\\System32\\lsass.exe" source="XmlWinEventLog:Security" action=success 
  | stats count by user ComputerName
  | rename user as Owner_Samaccountname]
| stats values(*) as * by Owner_Samaccountname
| table Time Owner_Samaccountname AccountUsed Department Target_Computer ComputerName
| sort - Time

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

graceojo34
Loves-to-Learn

Thanks for this, but it doesn't work because I can't match the fields because I don't have a common field. I have a lookup table for both logs. How can I use a lookup table to create a common field to regroup the fields.

 

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!

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...