How to Transform \n into line-break

Recently we came across a problem where the results of an OPAL query’s text “\n” was coming across in some customer alerts and was not turning into actual line breaks. Here is a doc that can help you solve this problem if you come across it.

Why was this occurring?

Inside of the string, it was stored as two characters ‘\’ and ‘n’. The symptoms can be seen in an alert where you are still seeing ‘\n’ inside of the text instead of line breaks.

How can a customer fix this?

The replace_regex function can be used to fix this problem. The following example will convert the ‘\n’ string into an actual line break when it is not. description is the input field name.

make_col description2:replace_regex(description,/\\n/,"\n")

Where can I find the documentation on replace_regex?

replace_regex - Observability Cloud documentation