Splunk Search

Fields Extraction using RegEx

syazwani
Path Finder

Hi, i want to extract bytes fields (using the bytes values) from this:

Sep 23 14:11:52 XXX.XXX.X.XX date=2021-09-23 time=14:11:52.004 device_id=FE-3KET123 log_id=6716781232 type=event subtype=smtp pri=information user=mail ui=mail action=NONE status=N/A session_id="47K0CjSc111111-47K0CjSc111111" msg="to=<XXXXXXXX@hotmail.com>, delay=00:00:04, xdelay=00:00:04, mailer=esmtp, pri=61772, relay=hotmail-com.olc.protection.outlook.com. [XXX.XX.XX.XXX], dsn=2.0.0, stat=Sent (<d97263bhagstbhbhet7c01f54636vfd37@GGP0HSDVVHHA9.XXX.XXX.XXX> [InternalId=32836723661134, Hostname=XXXXXXXXXX.namXXXX.prod.outlook.com] 71422 bytes in 0.303, 229.746 KB/sec Queued mail for delivery -> 250 2.1.5)"


I've already found the regex -    (?<bxmt>\d+) bytes
But it didnt seem to work fine.
Can anyone help?

Labels (1)
0 Karma
1 Solution

ashvinpandey
Contributor

@syazwani Try using the below rex:

| rex field=_raw "InternalId.*\]\s(?<bxmt>\d+?)\sbytes"

Also, If this reply helps you, an upvote would be appreciated.

View solution in original post

0 Karma

ashvinpandey
Contributor

@syazwani Try using the below rex:

| rex field=_raw "InternalId.*\]\s(?<bxmt>\d+?)\sbytes"

Also, If this reply helps you, an upvote would be appreciated.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It looks OK - how are you using it?

You could try using \s instead of spaces

\s(?<bxmt>\d+)\sbytes
0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...