Help sanitizing new lines

Hi there,

I need help with what I thought was a very simple issue, but turns out it isn't. I have updated from logstash 7.x to 8.x, and even though all of my tests have passed correctly, I found several issues with one of the pipelines that integrates firewall logs using a modified version of PFelk. It is more or less working now, but I still don't manage to receive logs from the "haproxy" side. I believe the problem is due to some new lines in the message. I don't what's changed and why they are a problem now, but I can't get rid of them. I have tried all the solutions proposed in similar posts, but none work.

Here's a sample log that is causing trouble:

"<30>Jan 29 10:29:46 haproxy[1087089]: 127.0.0.1:37672 [29/Jan/2025:10:29:46.258] HAProxyStats HAProxyStats/<STATS> 0/0/0/0/0 200 342208 - - LR-- 1/1/0/0/0 0/0 \"GET /stats HTTP/1.1\"\n"

In my tests, this type of input is discarded, not even recognized by logstash. In production it simply fails with a _grokparsefailure. I tried adding the gsub filter to remove "\n", but it doesn't do anything unless I escape the "\n" in the original message.

Any ideas on how I could solve this?

Hola Jose,

Could you please check below post incase if it is helpful?

Also could you please share if post upgrade these records are discarded by logstash & what is the error message we see in logstash?

Thanks!!

Turns out it was all a very funny mistake. I had the version pinned, so it did not upgrade to 8.X; however, my pipelines were changed to fit 8.X and changes made to pfelk... So yeah, that went very wrong... After I noticed and upgraded, everything slowly fell into place.

Just as a future confirmation, the mutate to remove "new lines" did work.