Splunk Search

Capture multiple values of same pattern in an event

nihvk
Explorer

How do we capture multiple URLs in a single event?

Log1:

type=EXECVE msg=audit(1695798790.101:25214323): argc=17 a1="http://127.0.0.1:8080" a2="http://10.0.2.20" a3="https://google.com/data/involvement/" a4=cat

 

Log2:

type=EXECVE msg=audit(1695798790.100:25214323):  a2="https://facebook.com" a3="-o" a4="http://127.0.0.1/index.html" a5="-kis" a6="-x" a7="http://10.0.0.10:8080"

 

Currently I'm using below regex which captures only one URL,

| rex field=_raw ".*\"(?<URL>((http|https):\/\/(\S+|\d+\.\d+\.\d+\.\d+\S+)))\""

Need all the URLs in the output.

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try without the greedy match at the beginning

| rex max_match=0 field=_raw "\"(?<URL>((http|https):\/\/(\S+|\d+\.\d+\.\d+\.\d+\S+)))\""

View solution in original post

nihvk
Explorer

I'm afraid, it still gives a single value output like this,

   URL

http://127.0.0.1:8080

https://facebook.com

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try without the greedy match at the beginning

| rex max_match=0 field=_raw "\"(?<URL>((http|https):\/\/(\S+|\d+\.\d+\.\d+\.\d+\S+)))\""

nihvk
Explorer

Fantastic! It worked. Thanks for the solution.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this

| rex max_match=0 field=_raw ".*\"(?<URL>((http|https):\/\/(\S+|\d+\.\d+\.\d+\.\d+\S+)))\""
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...