Splunk Search

search with lookup

corehan
Explorer

Hello dears,

I have switches, ip address,ports and i want list with users which are connected to the ports. Users informations include lookup file which name is list.csv, so;

list.csv contains : ip,port,user

<base_search>  | lookup list.csv ip as host AND port as if_name OUTPUT user |stats count by host,if_name,user

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

What is your question?

BTW, the lookup command does not recognize AND as a keyword.

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

corehan
Explorer

Exactly, so highleted with red. if match host and if_name with lookup file, then list user info.

Regards.

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Again I ask: What is your question?

So you know enough to highlight the syntax error in red, but not enough to look up the syntax and fix it?

Please describe the problem you are trying to solve.

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

corehan
Explorer

Sorry, i can't list with user info, i need lookup syntax which is check ip and port from lookup file. How can i do this with correct lookup syntax? I should check 2 multivalue field and than add to user info. I hope, understand.

<base_search>  | lookup list.csv ip as host AND port as if_name OUTPUT user |stats count by host,if_name,user

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The syntax for the lookup command is in the Search Reference manual at https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchReference/Lookup#Syntax

Did you try removing the AND keyword as I implied in my first reply?

I can't say I've tried it before, but I believe lookups do not work with multi-value fields.  You'll have to use mvindex or another multi-value function to get a single-value field for the lookup.

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

corehan
Explorer

Hello,

Now, i have some changes but still i can't list with lookup file's value;

<base search> |eval user_info=host."".Huawei_int |lookup fttb_user.csv ipport as user_info OUTPUT user |search user_info=10.58.35.144GigabitEthernet0/0/7 | stats count by Date,user_info,Huawei_status | sort -count |where count>6

Stats without user field;

corehan_0-1633384062035.png

 

Stats with user field;

corehan_1-1633384118621.png

lookup csv file;

corehan_2-1633384255583.png

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It's impossible to say why the data is not matching the lookup without seeing the data.  Please share some samples.

Also, the lookup command is specifying the 'user_info' field, which does not exist in the lookup file.

---
If this reply helps you, Karma would be appreciated.
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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...