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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...