Splunk Search

Lookup table with several IP ranges per row

pgomezji
Engager

Hi, I have a lookup table with IP ranges and locations. The problem is in the IP range column there can be several IP ranges separated by comma. How can match the client IP address with the right location?

Labels (1)
0 Karma
1 Solution

nickhills
Ultra Champion

To use a CIDR match you need each row in the lookup to have a single row per CIDR block.

So if your lookup has comma separated CIDR blocks you need to split these into rows.

You can either do this by manually splitting the data and adding rows, or you could use |inputlookup,  split the field, then mvexpand and re-write the (or create a new)  lookup.

 

 

| makeresults 
| eval cidr="192.168.1.0/24,192.168.30.0/24", location="London"
| table cidr location
| eval cidr=split(cidr,",")|mvexpand cidr

 

 

replace the first 3 lines with |inputlookup yourfile.csv
add at the end |outputlookup yourNewfile.csv to write a new file

| inputlookup yourfile.csv 
| eval cidr=split(cidr,",")|mvexpand cidr
| outputlookup yourNewfile.csv
If my comment helps, please give it a thumbs up!

View solution in original post

0 Karma

nickhills
Ultra Champion

To use a CIDR match you need each row in the lookup to have a single row per CIDR block.

So if your lookup has comma separated CIDR blocks you need to split these into rows.

You can either do this by manually splitting the data and adding rows, or you could use |inputlookup,  split the field, then mvexpand and re-write the (or create a new)  lookup.

 

 

| makeresults 
| eval cidr="192.168.1.0/24,192.168.30.0/24", location="London"
| table cidr location
| eval cidr=split(cidr,",")|mvexpand cidr

 

 

replace the first 3 lines with |inputlookup yourfile.csv
add at the end |outputlookup yourNewfile.csv to write a new file

| inputlookup yourfile.csv 
| eval cidr=split(cidr,",")|mvexpand cidr
| outputlookup yourNewfile.csv
If my comment helps, please give it a thumbs up!
0 Karma

pgomezji
Engager

Thanks, I was afraid of that answer.

0 Karma
Get Updates on the Splunk Community!

2024 Splunk Career Impact Survey | Earn a $20 gift card for participating!

Hear ye, hear ye! The time has come again for Splunk's annual Career Impact Survey!  We need your help by ...

Optimize Cloud Monitoring

  TECH TALKS Optimize Cloud Monitoring Tuesday, August 13, 2024  |  11:00AM–12:00PM PST   Register to ...

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...