Splunk Search

Regex - find second match?

cfortune
Explorer

Was hoping I could get some help with extracting a field. I have a line that looks like:

"2010-10-08 16:04:10 0.0.0.0 21 3236 255.255.255.255 22821 2312 username 0 0 - 22 Back from VerifyPassword(user=username), bPasswordOK=1, iRetCode=0"

I want to extract the 255.255.255.255 as src_ip. I understand how to extract the field but I can't come up with a regex that extracts only that second IP address (as it's the source, first is the destination and is always the same, of course these are made up in this example. I don't have broadcast addresses logging into my server). I even downloaded regexbuddy but I still can't figure it out because I'm lame.

Any help would be greatly appreciated.

Tags (1)
1 Solution

dwaddle
SplunkTrust
SplunkTrust

I think this will work - this is in transforms.conf style:

[mylookup]
REGEX=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} ([^\s]+) \d+ \d+ ([^\s]+)
FORMAT=src_ip::$2 dest_ip::$1

View solution in original post

dwaddle
SplunkTrust
SplunkTrust

I think this will work - this is in transforms.conf style:

[mylookup]
REGEX=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} ([^\s]+) \d+ \d+ ([^\s]+)
FORMAT=src_ip::$2 dest_ip::$1

cfortune
Explorer

Worked. Thanks man! Very quick response too.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...