Splunk Search

Help with regex / replace needed

damucka
Builder

Hello,

I have the following event:

X Mon Mar  4 19:57:48:935 2019 X  *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400

WARNING could be also ERROR, I would like to handle both cases in one regex.

Now, I would like to:
1/ Skip the line beginning until the word WARNING / ERROR
2/ clear the event from all digits
3/ save the result into the "text"

For the digit clearing I have the following replace:

| eval text=replace(_raw,"\d{0}\d+","")

and it works fine. However I have issues with the skipping line until WARNING / ERROR. If I take the regex101, then the corresponding sed would be:

s/^(.*)\* //g

but when I apply it in the Splunk SPL it will do nothing:

| rex mode=sed "s/^(.*)\*//g"

.. not mentioning trying above in replace.

Could you please advice?
How would I skip the beginning of line and clear it from digits and assign to the text? Replace or sed, does not matter.

Kind Regards,
Kamil

Tags (1)
0 Karma
1 Solution

vnravikumar
Champion

Hi @damucka

Try like and please let me know sample output that you want

| makeresults 
| eval _raw="X Mon Mar  4 19:57:48:935 2019 X  *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400" 
| eval text=replace(_raw,"\d{0}\d+","")| rex field=text mode=sed "s/^(.*)\*//g"

View solution in original post

0 Karma

chrisyounger
SplunkTrust
SplunkTrust

What about this:

|makeresults | eval _raw = "X Mon Mar 4 19:57:48:935 2019 X *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400" | rex mode=sed field=_raw "s/\d+//" |rex mode=sed "s/^(.*?)\*+//g"

0 Karma

vnravikumar
Champion

Hi @damucka

Try like and please let me know sample output that you want

| makeresults 
| eval _raw="X Mon Mar  4 19:57:48:935 2019 X  *** WARNING => MMX 'EGPH5': mm_diagmode set 0 118: possible performance degradation #102400" 
| eval text=replace(_raw,"\d{0}\d+","")| rex field=text mode=sed "s/^(.*)\*//g"
0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...