Splunk Search

How to search values in the lookup file?

prasant
Path Finder

I have sample.csv file with about 30000 rows with columns:

sample data

data 

value1    value2
5600012345    abc  xxx
7890012345    fsfs rwrr


I have below query

 

 

index="b2c"
|rex field=path1.path2.details "code=\'(?<data>[^\n\r\']{10})"

 

 

I can see the extracted 'data' field in the fields list.
I want to  query  'data' column values in the csv file and return table with the data and other fields from the event and csv file. how to use inputlookup or lookup command to search the extracted field? Thanks for the help in advance

Labels (1)
0 Karma

prasant
Path Finder

Thanks..not sure why I keep getting error.. this works though   | search [ | inputlookup sample.csv | fields data]|lookup sample.csv data local=true .
This returned all the other fields from csv file to the 'interesting fields' sidebar.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

FYI: 

All you need to show a lookup is

| inputlookup sample.csv

prefixing it with search and putting it in a subsearch is not necessary.

but doing that operation is a different thing to doing 

| lookup sample.csv data OUTPUT value1 value2

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

What you describe is exactly what the lookup command does.  You can read about it at https://docs.splunk.com/Documentation/Splunk/9.0.3/SearchReference/Lookup

index="b2c"
|rex field=path1.path2.details "code=\'(?<data>[^\n\r\']{10})"
| lookup sample.csv data OUTPUT value1 value2
---
If this reply helps you, Karma would be appreciated.
0 Karma

prasant
Path Finder

Thanks but getting Streamed search execute failed because: Error in 'lookup' command: Could not construct lookup error,

This works though  | search [ | inputlookup sample.csv | fields data]|
but how can I add the other corresponding columns from csv file along with the other fields from the event?

0 Karma

bowesmana
SplunkTrust
SplunkTrust

The lookup command @richgalloway gave should be correct and is definitely the right way to use a lookup.

Look at this question - it has similarities to yours

https://community.splunk.com/t5/Splunk-Search/Could-not-construct-lookup/m-p/503505

 

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...