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
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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...