Splunk Search

How to extract values from within a field?

nitz13
New Member

I have events of the following format:

 {  [-]      
         log:    2018-04-16 11:33:09 INFO  Report:46 - Number of Records read from Input File [10000] , number of records Posted [10000] to topic [completed.processing]
     stream:     stdout 

 time:   2018-04-16T16:33:09.36532399Z  

} }

Log is an extracted field and I want to extract the values "Number of records read from Input file and number of records posted" from within the field log and display it as a table of the following format:
Number of Input Records . Number of records posted
10000 10000

0 Karma

kmaron
Motivator

You should be able to use a regular expression to pull out the number of input records and number of records posted. Then make a table from them.

| makeresults 
| eval log="2018-04-16 11:33:09 INFO  Report:46 - Number of Records read from Input File [10000] , number of records Posted [10000] to topic " 
| rex field=log "Number of Records read from Input File \[(?<InputRecords>.*?)\] , number of records Posted \[(?<PostedRecords>.*?)\] to topic" 
| rename InputRecords as "Number of Input Records" PostedRecords as "Number of Records Posted" 
| table "Number of Input Records" "Number of Records Posted"
0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...