Getting Data In

How to exclude part of JSON before indexing

nareshinsvu
Builder

I want to exclude part of JSON message before indexing. How can I achieve that> Below is a sample JSON. I used SED command in props.conf to exclude the first line and make it only JSON Indexed extraction. And another 2 more SEDs in props.conf to ignore a section of XML message (part of below JSON) as well

How can I write SED to ignore the "ignore" section below?

2019-10-02_09:09:09.234 My JSON message is
{A_message
  {"blah": is blah
    "blah2": is blah2
    "blah3" : {
 blah blah blah
 }
   "Ignore this" :
 {
 "ignore1": ignore1
 ignore2: "ignore2"
}
}
0 Karma

diogofgm
SplunkTrust
SplunkTrust

Hi

You can use transforms to remove things before indexing.

[remove_ignore]
REGEX = (pattern before the data to ignore) data to ignore (pattern after data to ignore)
FORMAT = $1$2
DEST_KEY = _raw

Check the example in this answer:
https://answers.splunk.com/answers/485943/is-there-any-way-to-execute-sedcmd-after-transform.html

------------
Hope I was able to help you. If so, some karma would be appreciated.
0 Karma

ololdach
Builder

Hi nareshinsvu, this is a tough one. Until the data stream processor of Splunk is released, there is no easy way to efficiently do complex transformations on the data prior to ingestion. Depending on where the data comes from, you might want to take a look at implementing a modular input and preprocess the JSON in a small python script.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...