Getting Data In

How to exclude private ip address range based on the result of "rex max_match"

haiweichen
Explorer

I run this query to extract all IP address from the events. There are multi ip based on one event.

index=*
| rex max_match=0 field=_raw "(?<ipaddr>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
| dedup ipaddr
| table _time, ipaddr

 

The result is as below,

Capture.PNG

My question is, how to exclude private IP from the the result? Thanks!

Labels (1)
0 Karma
1 Solution

haiweichen
Explorer

Thanks, mvfilter works for my case. 

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

use the mvfilter function to remove unwanted values from a multi--value field.

| rex max_match=0 field=_raw "(?<ipaddr>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
| eval ipaddr=mvdedup(mvfilter(match(ipaddr,"10\..*")))
| table _time, ipaddr

Also, use mvdedup instead of dedup on multi-value fields.

---
If this reply helps you, Karma would be appreciated.
0 Karma

haiweichen
Explorer

Thanks, mvfilter works for my case. 

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 ...