Splunk Search

Help In Regex

jagadish85
Path Finder

I want to extract the previous line if found a matching string in an event.

for Eg in an event :
4XESTACKTRACE at com/mypackage/test/TestClass1.method1(TestClass1.java:558(Compiled Code))
4XESTACKTRACE at com/mypackage/test/TestClass1.method2(TestClass1.java:148(Compiled Code))
4XESTACKTRACE at com/mypackage/test/TestClass1.run(TestClass1.java:55(Compiled Code))

I want to get the package or line (com/mypackage/test/TestClass1.method2) before the line containing run method.

rex max_match=10 field=_raw "at (?Pcom/mypackage/[\w/]*.[\w]+)" giving me all.

Thanks
Jagadish

Tags (2)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

You could try something like to only get stuff from the line directly above a line that contains ".run"

rex "at (?<aaa>[^(]+)[^\r\n]+[\r\n]+[^\r\n]+\.run" | table aaa

/K

View solution in original post

0 Karma

kristian_kolb
Ultra Champion

You could try something like to only get stuff from the line directly above a line that contains ".run"

rex "at (?<aaa>[^(]+)[^\r\n]+[\r\n]+[^\r\n]+\.run" | table aaa

/K

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...