Splunk Search

How do I remove certain IP addresses with only 3 octets in the Search app?

luongg
Explorer

I have a file that contains a list of IP addresses (Some that are full IPv4 and some that only have an IP with the first 3 octets). I was able to upload the file into Splunk as a lookup file and search for it to display it on Splunk Web. Assuming that I have one column with a mixture of IP addresses that are either IPv4 (Ex: 10.4.123.11) or IPv4 with only the first 3 octets showing (Ex: 10.1.236). Is there an easy way to remove any IP address entries that only have the 3 octets?

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Not sure if I get the requirement completely. But give this a try.

| inputlookup yourlookup.csv | regex yourIpfield!="^\d+\.\d+\.\d+$"

View solution in original post

0 Karma

Raschko
Communicator

You could use a regex on the IP field, like:

your search | regex ipfield="^(?!\d{1,3}\.\d{1,3}\.\d{1,3}$)"
0 Karma

somesoni2
SplunkTrust
SplunkTrust

Not sure if I get the requirement completely. But give this a try.

| inputlookup yourlookup.csv | regex yourIpfield!="^\d+\.\d+\.\d+$"
0 Karma

luongg
Explorer

This worked out perfectly. Thanks for the help!

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...