Splunk Search

Regex for multiple IP Addresses in Splunk

asplunk123
New Member

In the below log we have User Agent fallowed by two Ip addresses. So i want to extract below fields

UserAgent , IPAdd2, IPAdd2

My Regex : (getting error)

rex (?.[a-zA-Z0-9-/^%?;.\s\w&()=-]+) | rex "^(?i)(?P[^ ,]+)(,(?P[^ ,]+))?"

Log :

"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/28.0" "158.69.213.225, 23.217.200.191"

Tags (1)
0 Karma

woodcock
Esteemed Legend

This will create a mult-valued field:

... | rex max_match=0 "(?<IPAddress>\d+\.\d+\.\d+\.\d+)"

You can use a more specific RegEx if you like, but the more complicated it is, the slower it will be, too, and simpler ones are unlikely to have false positives.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Quantify Your Splunk Investment Impact: Introducing Savings Metrics to Value Insights

Building on the foundation established in our initial Value Insights releases, we are introducing the Savings ...

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...