Splunk Search

Help extracting fields from raw event

hippe21
Explorer

Here's what my raw event looks like:

58daf92d66c83d000e469dfd.txt unsupported file format 

I'd like to extract the following below during a search, to pull these fields:

  • task = 58daf92d66c83d000e469dfd
  • fileExt = .txt
  • errorReason = unsupported file format

How can I accomplish this using Rex?

Tags (3)
0 Karma
1 Solution

gjanders
SplunkTrust
SplunkTrust

Maybe something like:

| rex "(?P<task>^[^\.]+)(?P<fileExt>\S+\s(?P<errorReason>.*)"

I'm unsure if that first part should be [^.] or [^.]

The built in regular expression creator could help here or sites like https://regex101.com/

View solution in original post

0 Karma

gjanders
SplunkTrust
SplunkTrust

Maybe something like:

| rex "(?P<task>^[^\.]+)(?P<fileExt>\S+\s(?P<errorReason>.*)"

I'm unsure if that first part should be [^.] or [^.]

The built in regular expression creator could help here or sites like https://regex101.com/

0 Karma

hippe21
Explorer

This is exactly what I needed, thank you!

0 Karma
Get Updates on the Splunk Community!

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...