Splunk Search

Mulit lookup with same event-field, lookup-destfield and event-destfield

Lukas85
New Member

Hi All

I'm new on splunk and have following problem.

We need data from a table depending on the value of a variable. For this lookup is the right function i think. The special on that csv/file is the value can be in different columns. Return data will be always the same. 

The csv table has following structur: 

column1column2column3column4column5
441F205E77889 22558
441F204E779984455633669
442G20718899266557 
442  1122311559

 

it's possible there is no value inside a field in the table.  In case we won't found a match on column2 we search in column 4 and last in column6. 

I tried it as follow:

 

 

| lookup Inventar_SBB column2   as Test_field output    "column1" as "value1" , "column3" as "value2", "column4" as "value3", "column5" as "value4" 
| lookup Inventar_SBB "column4" as Test_field outputnew "column1" as "value1" , "column3" as "value2", "column4" as "value3", "column5" as "value4" 
| lookup Inventar_SBB "column5" as Test_field outputnew "column1" as "value1" , "column3" as "value2", "column4" as "value3", "column5" as "value4"

 

 

It looks like lookup function returns NULL in case there is no match.  With outputnew it won't overwrite the NULL value and with output it always overwrite my values with NULL  

I tried with different variable names for "value" in each lookup and compare it to NULL but this was also not working. 

Any idea what could be the workaround for this problem?

Thanks in advance for any help.

Labels (1)
0 Karma

efika
Communicator

Hi @Lukas85 ,

Read the full set of column and use the function coalesce ( "This function takes an arbitrary number of arguments and returns the first value that is not NULL.")

| makeresults 1 
| eval column2=NULL,column3=NULL, column4=11223,column5=11559
| eval result= coalesce(column2,column3,column4,column5)

 

 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...