Getting Data In

How do I extract a whole sentence as a field from a log file and generate a report?

shubhambhagat02
New Member

I want to generate a report by using a log file as an input. The log file is like:

01/16/2018   process 1 successful 
01/16/2018  process 2 successful  
01/16/2018  process 3 successful    

I want "process 2 successful" as a field so that I can use the transforming command to generate a report.

Tags (1)
0 Karma
1 Solution

Vijeta
Influencer

Please use _raw instead of x

View solution in original post

0 Karma

Vijeta
Influencer

Please use _raw instead of x

0 Karma

Vijeta
Influencer

you can use rex command to extract the desired text

rex field=x "^\S+ (?<text>\w+\s+\d+\s+\w+)"

See the example below-

 | makeresults 
    |  eval x="2018/12/09 process 1 successful"
    | appendpipe
        [| eval x="2018/12/09 process 2 successful"
        | appendpipe
            [| eval x="2018/12/09 process 3 successful"]]
    |  rex field=x "^\S+ (?<text>\w+\s+\d+\s+\w+)"
0 Karma

shubhambhagat02
New Member

Thanks for answer.

I tried following your example rex field=x "^\S+ (?\w+\s+\d+\s+\w+)" but still i am not able to extract the fields.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...