Splunk Search

How can I extract the fields from log file?

nayagan
Engager

I need to split the below log files to like excel table.

My Log file is:

2022-05-25 13:00:02 100.200.190.70 - test [12345]dele /TestingFile+-+END+-+GOD+WEL+SOONER+-+SFTP.txt - 220- 105 - 443
2022-06-30 12:05:08 200.231.150.150 - welcome [98765]created /TestingFileFromSource+-+COME+-+THE+END+Server+-+FileName.csv - 226 - 19 - 22

Expected Result is: ( I tried some regular expression but no luck)

Field1 Field2 Field3 Field4 Field5 Field6 Field7 Field8 Field9
2022/05/25 13:00:02 100.200.190.70 test 12345 dele TestingFile END GOD WEL sooner SFTP.txt 220 105 443
2022/06/30 12:05:08 200.231.150.150 welcome 98765 created TestingFileFromSource COME THE END Sending FileName.csv 226 19 22
Labels (3)
Tags (1)
0 Karma

nayagan
Engager

Hi @gcusello - Thank you for your support, It is working fine now.  How to remove "+-+" in the field6. I need only file as TestingFileFromSource COME THE END Server FileName.csv instead of TestingFileFromSource+-+COME+-+THE+END+Server+-+FileName.csv

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @nayagan,

please try this regex

^(?<field1>\d+-\d+-\d+ \d+:\d+:\d+)\s+(?<field2>\d+\.\d+\.\d+\.\d+)\s+-\s+(?<field3>\w+)\s+\[(?<field4>\d+)\](?<field5>\w+)\s+\/(?<field6>.+)-\s+(?<field7>\d+)\s+-\s+(?<field8>\d+)\s+-\s+(?<field9>\d+)

that you can test at https://regex101.com/r/ozkFFe/1

Ciao.

Giuseppe

Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...