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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...