Getting Data In

Unable to remove prefix by SEDCMD in sourcetype but able to run in search

Alan_Chan
Explorer
I am trying to remove everything before the { character to preserve the JSON format. I am using SEDCMD-keepjson = s/^[^{]{/{/ in the sourcetype configuration, but it fails to apply correctly. However, when I use the search command | rex mode=sed "s/^[^{]{/{/", it successfully removes the unwanted text. I am wondering what could be causing this issue. The sourcetype settings are configured on both the Search Head (SH) and Heavy Forwarder (HF)


Mar 28 13:11:57 abcdeabcdev01w.abcdabcd.local {<json_log>}

Alan_Chan_0-1745733941390.png

 

Labels (1)
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @Alan_Chan 

Ive checked this config locally and it does work for your sample event so something else isnt right here. I think there is a typo in what you posted so I used the value from the screenshot, but please confirm you have the asterisk in your SEDCMD that is deployed?

Is the screenshot you sent from the Searchhead? Is the exact same config deployed to the Heavy Forwarder? And is this the only (or first) HF that the data lands on? 
How is the data arriving into the HF? If it is via HEC using the event endpoint then this configuration will not work and you would need to use INGEST_EVAL or move to the raw HEC endpoint.

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

Alan_Chan
Explorer

Hi @livehybrid 
The screenshot I sent is from the Search Head and shows the exact same configuration deployed to the Heavy Forwarder. This is the first Heavy Forwarder that the data lands on. The data is sent to the Heavy Forwarder using rsyslog, and the Heavy Forwarder uses [monitor:] to monitor the logs.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Alan_Chan ,

this transformation is unuseful on the SH, but it must be localized in the first HF that dara pass trhough, are you sure that you applied it in the first HF?

Then check if the sourcetype where you associated the SEDCMD command is the correct one, and that there isn't any transformation on this sourcetype.

Then, are you sure that is useful to remove these few chars?

Ciao.

Giuseppe

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...