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!

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...