Splunk Search

How to insert empty lines in the field before and after a specific pattern?

damucka
Builder

Hello,

I have a column / field called LINE that consists of the several text lines.
I would like to format it a bit before I present it to the end users in the alert using $result.LINE$.
I have there the following header line:

****************************

and I would like to insert two empty lines before and one empty line below of it into the LINE field.

How would I do it?

Kind Regards,
Kamil

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try rex.

... | rex field=LINE mode=sed "s/(\*{28})/\n\n\1\n/"
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try rex.

... | rex field=LINE mode=sed "s/(\*{28})/\n\n\1\n/"
---
If this reply helps you, Karma would be appreciated.
0 Karma

efavreau
Motivator

Also, @damucka make sure you accept the answer.

###

If this reply helps you, an upvote would be appreciated.
0 Karma

damucka
Builder

Thank you.
This would do what I want. One more question, how would the sed for the following header line look like?
... I am struggling with it a bit in regex101

******************************* MEMORY *************************************
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try "s/(\*+ MEMORY \*+)/\nn\1\n/".

---
If this reply helps you, Karma would be appreciated.
0 Karma

efavreau
Motivator

It would be best if you let each question stand alone, as well as state what you tried. However, try this:
https://regex101.com/r/xPYiLc/1

###

If this reply helps you, an upvote would be appreciated.
0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...