Splunk Search

How can i get ip address from postfix logs

saito0910
Engager

Hi,

How can i get ip address from like under log??

---
Sep 13 23:55:42 mailhost1 postfix/smtpd[15824]: [ID 197553 mail.info] connect from example.com[1.1.1.1]
---

I use search command "host=mailhost1 | top limit=100 client ",
and result is "example.com[1.1.1.1]".(source type is postfix_syslog)

I need only ip address to use geoip.

thanks

Tags (2)
0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi saito0910,

try something like this:

host=mailhost1 | rex field=client "(?<myIP>(\d+\.){3}\d+)]$" | top limit=100 myIP

this will get the IP form the client field and returns it as new field myIP

hope this helps ...

cheers, MuS

View solution in original post

MuS
SplunkTrust
SplunkTrust

Hi saito0910,

try something like this:

host=mailhost1 | rex field=client "(?<myIP>(\d+\.){3}\d+)]$" | top limit=100 myIP

this will get the IP form the client field and returns it as new field myIP

hope this helps ...

cheers, MuS

saito0910
Engager

Thanks MuS! That worked well! 🙂

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...