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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...