Splunk Search

lookup username from seperate search

justinhart
Path Finder

I am performing a search on some data that contains the computername, drive letter, and path of drives mapped to the computer. I also have a second search that returns the username associated with the computer. How can I add a field to the first search that ties the computername in search 1 to the username in search 2. Can I do this with a eval/subsearch or by doing a lookup to a csv file?

Thanks.

Tags (3)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

You can probably do this by a subsearch if you just want to find a mapped paths, drive letter etc from a single user, but it's a bit hard to say since you don't give all that much information of your desired output or sample logs.

Otherwise you might have to resort to a join, which is rather expensive.

The join approach would give you something like

sourcetype=A | join COMPUTERNAME [search sourcetype=B | fields COMPUTERNAME, USER_NAME] | table USER_NAME, COMPUTERNAME, DRIVELETTER, PATH

More information would allow you to get better help.

/Kristian

View solution in original post

0 Karma

kristian_kolb
Ultra Champion

You can probably do this by a subsearch if you just want to find a mapped paths, drive letter etc from a single user, but it's a bit hard to say since you don't give all that much information of your desired output or sample logs.

Otherwise you might have to resort to a join, which is rather expensive.

The join approach would give you something like

sourcetype=A | join COMPUTERNAME [search sourcetype=B | fields COMPUTERNAME, USER_NAME] | table USER_NAME, COMPUTERNAME, DRIVELETTER, PATH

More information would allow you to get better help.

/Kristian

0 Karma

justinhart
Path Finder

Thanks, this seemed like the easiest way to get what I was wanting.

0 Karma

Kate_Lawrence-G
Contributor

I think a subsearch would do the trick if you need to look up the username/computername data dynamically.

sourcetype=<src-1> computername=* 
[source=<src-2> computername=* | fields username ] 
| stats values(username)....by computername

But if you had a list of computernames and usernames available as a CSV you could do a lookup table as well at the end.

sourcetype=* | stats values(computername) AS computername | lookup user_table computername OUTPUT username AS "User"
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 ...