Splunk Search

search against a lookup table

linwqg
New Member

Need help. How to I obtain the following output? I tried the following SPL but doesn't work.

index=car_record | search [inputlookup sale.csv | table car_brand]

alt text

Tags (1)
0 Karma

logloganathan
Motivator

index=car_record [| inputlookup sale.csv | rename car_brand as car_type | table car_type ] | table car_type price quantity date

0 Karma

niketn
Legend

@linwqg, please try the following and confirm:

index=car_record  [| inputlookup sale.csv | rename car_brand as car_type | table car_type]
| <yourRemainingSearch>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

linwqg
New Member

Oh, the technique works again.

But then, what if I want to search through all field instead of just car_type field?

0 Karma

niketn
Legend

You would need to use the format command from Splunk. Try running the following search and you will see what search filter will be applied

| inputlookup sale.csv
| table *
| format
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

linwqg
New Member

I tried to read up on format cmd.

| inputlookup sale.csv
| table car_brand
| format

The above will create a search from car_brand field. And using the search, i can append to the orig search based on index=car_record?

0 Karma

niketn
Legend

@linwqg, I think I misunderstood your question. I thought you have multiple fields in your lookup file and you wanted to search those field values in your index.

I think your question is to search for the value from lookup across your index, not just limited to field car_type. If that is so all you need to do is | rename car_brands as search in your inputlookup command and then do a | table search. Please try the following and confirm:

 index=car_record  [| inputlookup sale.csv | rename car_brand as search | table search]
 | <yourRemainingSearch>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...