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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...