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
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...