Splunk Search

lookup csv but need to the lookup file contains several fields that need to be concatenated to match event field

loganramirez
Path Finder

Hi.

I have a lookup file with phone numbers broken down into their parts, so:
cc,npa,nxx,list
1,210,5551234,good
1,512,7779876,bad

My event stream has e164 phone numbers, so:
+12105551234
+15127779876

i'd like to use the lookup command, but can't find a way to natively join this data and looking for ideas.

currently i am able to use join, like this:

 

 

 

...
| join number
[
| inputlookup lookupfile.csv | eval number="+".cc.npa.nxx

 

 

 


but I've learned through this group mostly to try and avoid 'join' because of limitations and 'it basically applying SQL and this ain't SQL'.

I thought about 'breaking apart' the number field into (3) fields and then passing several looks like in the example page linked above, but this feels backwards when what i'd prefer to do is join the data in the csv.

So another idea was to create a report that does that and creates a new CSV (|output lookup), but that feels unnecessary, too.

Any thoughts?

THANK YOU!

 

 

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

The way to do it is to split the number up and do your lookup using those fields in a single lookup passing all three fields

| rex  field=number "\+(?<cc>\d)(?<npa>\d\d\d)(?<nxx>\d+)"
| lookup lookupfile.csv cc npa nxx

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

The way to do it is to split the number up and do your lookup using those fields in a single lookup passing all three fields

| rex  field=number "\+(?<cc>\d)(?<npa>\d\d\d)(?<nxx>\d+)"
| lookup lookupfile.csv cc npa nxx

 

loganramirez
Path Finder

Amazing!  Appreciate the straight up regex, too.  This was the way I thought I'd have to do, but didn't realize it 'exact matched' all three keyes (all 3 have to match to be accepted).

Thank you!!!

 

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...