Splunk Search

Can I create a multivalue field in a search?

bfaber
Communicator

If I have data like this:

src=1.1.1.1 dst=2.2.2.2

can I create a mvfield of ip's? like:

ips=1.1.1.1,2.2.2.2

FROM SPLUNKWEB (and not the config files)?

1 Solution

Lowell
Super Champion

Yes, you can.

Try something like this

<your search> | rex max_match=2 "(?:src|dst)=(?<ips>\d+\.\d+\.\d+\.\d+)"

You can increase max_match to a higher value if you more than just 2.

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

If src and dst are already fields (they would be auto-extracted by default), you could do this:

... | eval ips=src+","+dst" | eval ips=split(ips,",")

in 4.1+, or

... | eval ips=src+","+dst" | makemv ips delim=","

in earlier versions.

Lowell
Super Champion

Yes, you can.

Try something like this

<your search> | rex max_match=2 "(?:src|dst)=(?<ips>\d+\.\d+\.\d+\.\d+)"

You can increase max_match to a higher value if you more than just 2.

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