Splunk Search

Common regex

Jananee_iNautix
Path Finder

I have log statement as follows as

1.20131220.server-0.log:2013-12-20 09:38:00,852 [fewfg424] SUCCESS: The FTP Server [et - FTP SERVER] uploaded file [Transaction_2_113237579.csv] of length 1989 bytes from userid [EBIDWNID].
2.20131209.dbg.log:2013-12-09 17:52:12,435 [58c858c8] SUCCESS: File successfully uploaded using SFTP. Filename was [nv_afis_nav_download12092013145008.csv]. File length was [1403].
3.20131220.dbg.log:2013-12-20 09:36:35,575 [a468a] SUCCESS: File successfully uploaded using FTP. Filename [COR0083700_1.txt]. File length [5366] bytes.

I want to write a regex common to these three statements to extract the filename and file length and display in table.Can anyone say how to write a common regex to extract filename and length.

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

I agree with Ayn, but perhaps something like the following will be useful.

'... | rex ".*?\[(?<filename>[\S]*?)\].*\slength[^0-9]*(?<length>[0-9]+)" | ...'

---
If this reply helps you, Karma would be appreciated.
0 Karma

Jananee_iNautix
Path Finder

Thanks its working.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

All the more reason to use separate regexes, but I think this will help you.
(?i)file.*?\[(?<filename>[\S]*?)\].*\slength[^0-9]*(?<length>[0-9]+).

BTW, I like to use http://www.regextester.com/index.html for testing regex strings.

---
If this reply helps you, Karma would be appreciated.
0 Karma

Jananee_iNautix
Path Finder

It is not extracting the correct filename.So i have updated my question with the complete log.Can you see to that log and suggest me the correct regex.

0 Karma

aholzer
Motivator

I concur with Ayn. Just name the fields the same on the three regex's and you will still be able query across them.

0 Karma

Ayn
Legend

Why would you want one common regex? It's easier to split this up into separate regexes since your messages are pretty different.

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!

Federated Search for Snowflake Is Now Generally Available on Splunk Cloud Platform

Unlocking Data-In-Place Search Across Splunk and Snowflake  Enterprise data is increasingly distributed across ...

Help Us Build Better Splunk Regex Puzzles (And Win Prizes!)

If you’ve spent any time in the Splunk Community Slack, you’ve likely seen our resident Splunk Trust ...

Fuel Your Journey: What’s Waiting for You at the .conf26 Acceleration Station

Navigating the show floor at .conf26 isn't just about keynotes and technical breakout sessions; it's also ...