Splunk Search

How to edit my regex to extract multiple values for a field?

kedjjang
Explorer

Hello,

There is one event.

ex)Normal|2016-05-18 10:52:37|123|119.21.7.28|10460|tcp|52.1.2.157|68|allowed|72|12|External|71.100.3.17|17|ftp

I would like to extract multiple values in one field using regular expressions.

Example:

index=network | head 1| rex "(?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"

Right now, only one of the field values is extracted.
Example: ip_addr = 119.21.7.28

I want:
ip_addr = 119.21.7.28
ip_addr = 52.1.2.157
ip_addr = 71.100.3.17

0 Karma

Richfez
SplunkTrust
SplunkTrust

You'll probably want to add the optional parameter max_match=<int> and set it to 0 for unlimited matches.

index=network | rex max_matches=0 "(?<ip_addr>\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})"

Give that a whirl and report back if that's what you need!

Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...