Alerting

How to covert raw log to specific fields?

splunklearner99
Engager

Hello Champs..

One of the splunk log is having below field

Text: XCOM: File Receive ended REQ 086094, Remote LU 10.38.46.122, File $PRD10.C221130A Remotefile /ABC/APP1/OUT/C221130A 63465 bytes, 578 records in 38875 microsec

I want to extract File_name = $PRD10.C221130A and Remote_file = /ABC/APP1/OUT/C221130A and records = 578 from above Text filed. How this can be done? Please help

0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try this - note the ? after the .+

| rex "File\s(?<File_name>\S+)\s*Remotefile\s(?<Remote_file>\S+).+?(?<records>\d+)\srecords"

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "File\s(?<File_name>\S+)\s*Remotefile\s(?<Remote_file>\S+).+(?<records>\d+)\srecords"
0 Karma

splunklearner99
Engager

Thanks @ITWhisperer , the query is giving below result

File_name = $PRD10.C221130A

Remote_file = /ABC/APP1/OUT/C221130A

rerecords = 3

For records your query is taking the first byte of microsecond, expected 578 records

raw log: File $PRD10.C221130A Remotefile /ABC/APP1/OUT/C221130A 63465 bytes, 578 records in 38875 microsec

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this - note the ? after the .+

| rex "File\s(?<File_name>\S+)\s*Remotefile\s(?<Remote_file>\S+).+?(?<records>\d+)\srecords"
0 Karma

splunklearner99
Engager

thanks @ITWhisperer , Similarly would be able to help for thisText: CBM042 CEDBatch finished, Chg=B221205D, Recs=2581, Errs=8

Where I need

Status = CEDBatch finished

Records = 2581

Errors =9

Change = B221205D

@ITWhisperer

@ITWhisperer

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\w+\s(?<status>[^,]+), Chg=(?<change>\w+), Recs=(?<records>\d+), Errs=(?<errors>\d+)"

https://regex101.com/r/nbhKPz/1

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!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...