Splunk Search

How do I compare lookup field to search and print another field in lookup file?

cyrus_thesplunk
Engager

Currently in my logs I am getting the hostname of the users but not their usernames. I created a lookup table that contains hostnames and usernames. I am trying to match the hostname from search to the hostname in the lookup file and then print their correlated username in a table format in the search visualization. 

Lookup file:

hostnameusername
host1user1
host2user2
host3user3
host4user4

 

search:
index=windows sourcetype:eventlogs 
[|inputlookup users.csv | fields hostname username | rename hostname as users]
~~~print username correlated to "users" in the above string.~~~

Labels (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

index="windows" AND sourcetype="eventlogs"
| lookup users.csv hostname AS host OUTPUT username AS users
| table _time Time Hostname Username Src IP

View solution in original post

0 Karma

woodcock
Esteemed Legend

index="windows" AND sourcetype="eventlogs"
| lookup users.csv hostname AS host OUTPUT username AS users
| table _time Time Hostname Username Src IP

0 Karma

cyrus_thesplunk
Engager

Thank you! This worked perfectly

0 Karma

somesoni2
Revered Legend

You would need to use "lookup" command to enrich your data from lookup table fields, like this

index=windows sourcetype:eventlogs 
| lookup users.csv hostname as host OUTPUT username as users
0 Karma

cyrus_thesplunk
Engager

Got it. I understand this part but where are you comparing the hostname in the search to hostname in the lookup file and then printing the username correlated to that hostname in the table.

This is what the search visualization results should look like.

TimeHostnameUsernameSrc IP
5:01 amhost1user1192.xxx.xxx.xxx
5:07 amhost2user2192.xxx.xxx.xxx
5:09 amhost3user3192.xxx.xxx.xxx


Username information is the only thing thats coming from the lookup file. Rest of it comes from the search. 

0 Karma
Get Updates on the Splunk Community!

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...

Adoption of Infrastructure Monitoring at Splunk

  Splunk's Growth Engineering team showcases one of their first Splunk product adoption-Splunk Infrastructure ...