Splunk Search

How to edit my rex search to extract two different or duplicate IP addresses at the same time?

cyberportnoc
Explorer

Current search:

search "xxx" | rex field=_raw "api:(?\s\d+.\d+.\d+.\d+)"

I'm using the rex command, but it does not return the expected result when there are two IP addresses.

0 Karma
1 Solution

sundareshr
Legend

If both IPs are in the same event with "api" before it, you can use max_match, like this

search "xxx" | rex max_match=0 field=_raw "api:\s?(?<IP>\d+.\d+.\d+.\d+)" | mvexpand IP | table IP

If they are not in the same event, will need to see some sample events.

http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/Regex

View solution in original post

sundareshr
Legend

If both IPs are in the same event with "api" before it, you can use max_match, like this

search "xxx" | rex max_match=0 field=_raw "api:\s?(?<IP>\d+.\d+.\d+.\d+)" | mvexpand IP | table IP

If they are not in the same event, will need to see some sample events.

http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/Regex

richgalloway
SplunkTrust
SplunkTrust

Please share some sample events.

---
If this reply helps you, Karma would be appreciated.
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 ...