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!

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 ...