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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...