Splunk Search

How to extract string from a position until the end of line?

mdzmuran
Observer

I have lines like this:

[2011/02/11@10:33:13.978+0100] P-18679      T-0     I Usr     2: (49)    SYSTEM ERROR: Memory violation.

How can I extract the string beginning with "Memory viol" till the end of line? The string is one line only, but may be much longer with any characters.

0 Karma
1 Solution

DalJeanis
SplunkTrust
SplunkTrust

Your regex will look like this

| rex field=_raw "(?<myfield>Memory viol.*)$"

or you might prefer

| rex field=_raw "SYSTEM ERROR:\s+(?<myfield>.*)$"

Both of these assume that there will never be any fields after the system error. The $ at the end is a regex anchor for "the end of the field we are searching"

View solution in original post

DalJeanis
SplunkTrust
SplunkTrust

Your regex will look like this

| rex field=_raw "(?<myfield>Memory viol.*)$"

or you might prefer

| rex field=_raw "SYSTEM ERROR:\s+(?<myfield>.*)$"

Both of these assume that there will never be any fields after the system error. The $ at the end is a regex anchor for "the end of the field we are searching"

mdzmuran
Observer

Thanks. It works.

0 Karma
Get Updates on the Splunk Community!

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 ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...