Getting Data In

How to extract all log events excluding JSON messages?

nareshinsvu
Builder

Hi,

I want to extract all the log events (normal lines) except JSON messages. There should be an easy way for this. Any hints, please?

 

My log file is a mix something like below

----------

normal line

normal line

json events {

{json messages}

}

normal line

etc

etc

 

Thanks,

Naresh

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

If you can produce a regular expression that defines a JSON event then you can use a transform to filter them out.

Put this in a tranforms.conf file

[indexdata]
REGEX = .
DEST_KEY = queue
FORMAT = indexQueue

[filterjson]
REGEX = <your regex that detects JSON messages>
DEST_KEY = queue
FORMAT = nullQueue

Then add this to the corresponding props.conf file:

[mysourcetype]
TRANSFORMS-nojson = indexdata, filterjson
---
If this reply helps you, Karma would be appreciated.
0 Karma

nareshinsvu
Builder

Hi @ 

 

I am struggling with regex actually.  My regex is only capturing partial json message (until the first "}")

I am trying to search all lines between "line starting with {" and "line starting with }". But ^ is not picking my search

So, I am stuck with this regex currently   --    \{[\s\S]*?\}

{

  {

    {},

  },

}.

0 Karma

to4kawa
Ultra Champion

@nareshinsvu 

Regular expressions require a fairly strict definition. You haven't presented anything here.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...