Splunk Search

Query logs with IP and not domain name from a field in Splunk

masfar
Engager

Hi- I am trying to search through logs and looking for requests that are using IPs(IPv4) rather than domain name. How do I perform such query from a field, X?

For example:
111.222.333.444/abc.txt
myexample.com/xyz.txt

I want to look for logs with fields like line 1 and not line 2.

Thanks,
MA

Tags (1)
0 Karma

DalJeanis
Legend

This will test whether an ip address is anywhere in HostFieldName

... | eval n=if(match(HostFieldName,"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"), 1,0)

so, it would match WE123.456.789.012FX as well as your examples.

With minor adjustments, you could also use it something like this -

... | search match(HostFieldName,"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")
0 Karma
Get Updates on the Splunk Community!

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...