Getting Data In

Removing newline and carriage return

avanijjain16
Explorer

Hi, 

I am new to splunk. I am trying to make my logging message format good. 

I have log message with newline or carriage return not sure which one but when I try to replace it using 

rex field=message mode=sed "s/^[\r\n]+//g" it does not work, Any suggestions? I am not sure if there are any spaces or white spaces but I also tried with s/^/S*[\r\n]+//g

 

Message:

Line1

Line2

Line3

Expected :


Line1
Line2
Line3

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Your sed matches to [\r\n] at the beginning of the field - could it be at the end? Also, are these 3 instance of the message field or multi-line with the same message instance?

Get Updates on the Splunk Community!

App Platform's 2025 Year in Review: A Year of Innovation, Growth, and Community

As we step into 2026, it’s the perfect moment to reflect on what an extraordinary year 2025 was for the Splunk ...

Operationalizing Entity Risk Score with Enterprise Security 8.3+

Overview Enterprise Security 8.3 introduces a powerful new feature called “Entity Risk Scoring” (ERS) for ...

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...