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!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...