Splunk Search

Rex and Regex Field Extraction

mistertj3
Engager

Hello all,

I am trying to extract fields (tried the dynamic extraction and manual using rex&regex) but am unable to get it just right. My data looks like the following:

Apr 30 00:48:25 "ip_address" Apr 30 2012 00:48:25: %ASA-4-113019: Group = "Group",
Username = "User", IP = "ip_address",
Session disconnected. Session Type: SSL, Duration: 1h:59m:24s, Bytes xmt: 86659734,
Bytes rcv: 4557700, Reason: User Requested

I would like to extract the Bytes xmt and Bytes rcv to separate fields (on search time). Then I would like pipe to an eval statement that adds them then another pipe to the timechart.

I have tried a lot of regex and rex combinations using this site regular expression reference as a ref . But I've only gotten as far as rex field=_raw "Bytes xmt: (?.,)" , which only gives the first decimal?

I am probably doing this entirely wrong as this is my first expression so any help you can give would be great!

Thank you,

Tags (1)
0 Karma
1 Solution

lain179
Communicator

How about


rex field=_raw ".*Bytes xmt: (?<bxmt>\d+), Bytes rcv: (?<brcv>\d+),.*"

View solution in original post

lain179
Communicator

How about


rex field=_raw ".*Bytes xmt: (?<bxmt>\d+), Bytes rcv: (?<brcv>\d+),.*"

mistertj3
Engager

Got it and now have a better understanding of rex&regex. Thank you for all of your help and prompt responses!

0 Karma

sowings
Splunk Employee
Splunk Employee

Edited to show the backslashes.

cphair
Builder

There should be backslashes in front of the d+ characters. The comment forum doesn't always post them properly.

0 Karma

mistertj3
Engager

Thank you for your prompt response. I've copied and pasted what you've wrote, but the extracted fields bxmt and brcv do not show up under the selected fields nor interesting fields, so seemingly they have not been extracted. Is there something I'm missing or do I just pipe the additional statements (eval and timechart)?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...