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!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...