Splunk Search
Highlighted

Lookup command - multiple input fields

Motivator

Hi,

is it possible to use more than one input field within a lookup command?
The lookuptable looks like this:

User | Country | FieldA

I tried it like this, but it didn't work:

| lookup lookup.csv User, Country OUTPUT fieldA

BR

Heinz

Tags (2)
Highlighted

Re: Lookup command - multiple input fields

SplunkTrust
SplunkTrust

Hi HeinzWaescher,

see the docs about lookup

Note: The lookup command can accept multiple lookup and local fields and destfields. For example:

lookup <lookup-table-name> <lookup-field1> AS <local-field1>, <lookup-field2> AS <local-field2> OUTPUTNEW <lookup-destfield1> AS <local-destfield1>, <lookup-destfield2> AS <local-destfield2>

the only thing you must be aware of, is that the local-field should exists if you use it in a lookup. That would be in your use case User and Country.

hope this helps ...

cheers, MuS

View solution in original post

Highlighted

Re: Lookup command - multiple input fields

SplunkTrust
SplunkTrust

or are you using inputlookup because you are providing a lookup.csv in your example?

Highlighted

Re: Lookup command - multiple input fields

Motivator

Hi MuS,

I'm not using inputlookup, the table is just called lookup.csv.

The inputfields are existing in the lookuptable and the event. It is an "and" combination of the inputfields, correct? So the lookup should work and add fieldA for an event, when this combination "User/Country" exists in the lookuptable as well.

0 Karma
Highlighted

Re: Lookup command - multiple input fields

SplunkTrust
SplunkTrust

let's take this example,

col1,col2,col3,col4
100,300,500,yes
200,400,600,no

Configure this a lookup named mylookup and you can use the lookup in a search like this:

basesearch | lookup mylookup col1 as field1, col2 as field2, col3 as field3 OUTPUT col4

For each event where all the input values matches, there will be a resulting field, col4, available for that event.
So if you have field1=100 AND field2=300 AND field3=500 then you will get back col4=yes

Highlighted

Re: Lookup command - multiple input fields

Communicator

I wonder if it's possible to do "OR" logic, instead of "AND" logic?
Say, if I have field1=100 OR field2=300 OR field3=500 then I will get back col4=yes

Highlighted

Re: Lookup command - multiple input fields

Communicator

To make an OR you just make multiple lookup with OUTPUTNEW instead of OUTPUT

my search
| lookup mylookup col1 AS field1 OUTPUTNEW col4
| lookup mylookup col2 AS field1 OUTPUTNEW col4
| lookup mylookup col3 AS field1 OUTPUTNEW col4
Highlighted

Re: Lookup command - multiple input fields

Explorer

Thank you for this one mate, it helps !

0 Karma
Highlighted

Re: Lookup command - multiple input fields

Motivator

thank you!

0 Karma
Highlighted

Re: Lookup command - multiple input fields

Motivator

After some adjustments in my search, it works like expected. Thanks a lot 🙂

0 Karma